Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,19 +429,20 @@ void Tablet::delete_expired_stale_rowset() {
return;
}

const RowsetSharedPtr lastest_delta = rowset_with_max_version();
if (lastest_delta == nullptr) {
LOG(WARNING) << "lastest_delta is null " << tablet_id();
return;
}
// do check consistent operation
auto path_id_iter = path_id_vec.begin();

std::map<int64_t, PathVersionListSharedPtr> stale_version_path_map;
while (path_id_iter != path_id_vec.end()) {

PathVersionListSharedPtr version_path = _timestamped_version_tracker.fetch_and_delete_path_by_id(*path_id_iter);
const std::vector<TimestampedVersionSharedPtr>& to_delete_version = version_path->timestamped_versions();

auto first_version = to_delete_version.front();
auto end_version = to_delete_version.back();
Version test_version = Version(first_version->version().first, end_version->version().second);

Version test_version = Version(0, lastest_delta->end_version());
stale_version_path_map[*path_id_iter] = version_path;

OLAPStatus status = capture_consistent_versions(test_version, nullptr);
Expand Down
25 changes: 14 additions & 11 deletions be/src/olap/version_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,19 +101,11 @@ void TimestampedVersionTracker::_init_stale_version_path_map(
// 2.1 find a path in stale_map can replace current stale_meta version
bool r = _find_path_from_stale_map(stale_map, stale_meta->start_version(), stale_meta->end_version(), &stale_path);

// 2.2 add stale_meta to stale_map
auto start_iter = stale_map.find(stale_meta->start_version());
if (start_iter != stale_map.end()) {
start_iter->second[stale_meta->end_version()] = stale_meta;
} else {
std::unordered_map<int64_t, RowsetMetaSharedPtr> item;
item[stale_meta->end_version()] = stale_meta;
stale_map[stale_meta->start_version()] = std::move(item);
}
// 2.3 add version to version_graph
// 2.2 add version to version_graph
Version stale_meta_version = stale_meta->version();
add_version(stale_meta_version);
// 2.4 find the path

// 2.3 find the path
if (r) {
// add the path to _stale_version_path_map
add_stale_path_version(stale_path);
Expand All @@ -126,6 +118,16 @@ void TimestampedVersionTracker::_init_stale_version_path_map(
}
}
}

// 2.4 add stale_meta to stale_map
auto start_iter = stale_map.find(stale_meta->start_version());
if (start_iter != stale_map.end()) {
start_iter->second[stale_meta->end_version()] = stale_meta;
} else {
std::unordered_map<int64_t, RowsetMetaSharedPtr> item;
item[stale_meta->end_version()] = stale_meta;
stale_map[stale_meta->start_version()] = std::move(item);
}
}

// 3. generate stale path from rs_metas
Expand Down Expand Up @@ -189,6 +191,7 @@ bool TimestampedVersionTracker::_find_path_from_stale_map(
while (map_iter != second_version_map.end()) {
// the version greater than second_version, we can't find path in stale_map
if (map_iter->first > second_version) {
map_iter++;
continue;
}
// backtracking _find_path_from_stale_map find from map_iter->first + 1 to second_version
Expand Down