Skip to content

Commit

Permalink
[enhancement](rowset-meta) Remove rowset meta from olap meta directly… (
Browse files Browse the repository at this point in the history
  • Loading branch information
TangSiyang2001 authored Nov 6, 2024
1 parent 132d885 commit 9096671
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
3 changes: 2 additions & 1 deletion be/src/olap/cold_data_compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include "common/compiler_util.h" // IWYU pragma: keep
#include "common/config.h"
#include "common/status.h"
#include "io/fs/remote_file_system.h"
#include "olap/compaction.h"
#include "olap/olap_common.h"
Expand Down Expand Up @@ -97,7 +98,7 @@ Status ColdDataCompaction::modify_rowsets() {
std::lock_guard wlock(_tablet->get_header_lock());
SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
// Merged cooldowned rowsets MUST NOT be managed by version graph, they will be reclaimed by `remove_unused_remote_files`.
tablet()->delete_rowsets(_input_rowsets, false);
RETURN_IF_ERROR(tablet()->delete_rowsets(_input_rowsets, false));
tablet()->add_rowsets({_output_rowset});
// TODO(plat1ko): process primary key
_tablet->tablet_meta()->set_cooldown_meta_id(cooldown_meta_id);
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/schema_change.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ Status SchemaChangeJob::_do_process_alter_tablet(const TAlterTabletReqV2& reques
}
}
std::vector<RowsetSharedPtr> empty_vec;
_new_tablet->delete_rowsets(rowsets_to_delete, false);
RETURN_IF_ERROR(_new_tablet->delete_rowsets(rowsets_to_delete, false));
// inherit cumulative_layer_point from base_tablet
// check if new_tablet.ce_point > base_tablet.ce_point?
_new_tablet->set_cumulative_layer_point(-1);
Expand Down
21 changes: 12 additions & 9 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ Status Tablet::revise_tablet_meta(const std::vector<RowsetSharedPtr>& to_add,
// error handling
if (!calc_bm_status.ok()) {
if (is_incremental_clone) {
delete_rowsets(to_add, false);
RETURN_IF_ERROR(delete_rowsets(to_add, false));
LOG(WARNING) << "incremental clone on tablet: " << tablet_id() << " failed due to "
<< calc_bm_status.msg() << ", revert " << to_add.size()
<< " rowsets added before.";
Expand All @@ -438,7 +438,7 @@ Status Tablet::revise_tablet_meta(const std::vector<RowsetSharedPtr>& to_add,

// full clone, calculate delete bitmap succeeded, update rowset
if (!is_incremental_clone) {
delete_rowsets(to_delete, false);
RETURN_IF_ERROR(delete_rowsets(to_delete, false));
add_rowsets(to_add);
// reconstruct from tablet meta
_timestamped_version_tracker.construct_versioned_tracker(_tablet_meta->all_rs_metas());
Expand Down Expand Up @@ -611,30 +611,33 @@ void Tablet::add_rowsets(const std::vector<RowsetSharedPtr>& to_add) {
_tablet_meta->modify_rs_metas(rs_metas, {});
}

void Tablet::delete_rowsets(const std::vector<RowsetSharedPtr>& to_delete, bool move_to_stale) {
Status Tablet::delete_rowsets(const std::vector<RowsetSharedPtr>& to_delete, bool move_to_stale) {
if (to_delete.empty()) {
return;
return Status::OK();
}
std::vector<RowsetMetaSharedPtr> rs_metas;
rs_metas.reserve(to_delete.size());
for (auto& rs : to_delete) {
for (const auto& rs : to_delete) {
rs_metas.push_back(rs->rowset_meta());
_rs_version_map.erase(rs->version());
}
_tablet_meta->modify_rs_metas({}, rs_metas, !move_to_stale);
if (move_to_stale) {
for (auto& rs : to_delete) {
for (const auto& rs : to_delete) {
_stale_rs_version_map[rs->version()] = rs;
}
_timestamped_version_tracker.add_stale_path_version(rs_metas);
} else {
for (auto& rs : to_delete) {
for (const auto& rs : to_delete) {
_timestamped_version_tracker.delete_version(rs->version());
if (rs->is_local()) {
_engine.add_unused_rowset(rs);
RETURN_IF_ERROR(RowsetMetaManager::remove(_data_dir->get_meta(), tablet_uid(),
rs->rowset_meta()->rowset_id()));
}
}
}
return Status::OK();
}

RowsetSharedPtr Tablet::_rowset_with_largest_size() {
Expand Down Expand Up @@ -2011,7 +2014,7 @@ Status Tablet::_cooldown_data(RowsetSharedPtr rowset) {
std::unique_lock meta_wlock(_meta_lock);
SCOPED_SIMPLE_TRACE_IF_TIMEOUT(TRACE_TABLET_LOCK_THRESHOLD);
if (tablet_state() == TABLET_RUNNING) {
delete_rowsets({std::move(old_rowset)}, false);
RETURN_IF_ERROR(delete_rowsets({std::move(old_rowset)}, false));
add_rowsets({std::move(new_rowset)});
// TODO(plat1ko): process primary key
_tablet_meta->set_cooldown_meta_id(cooldown_meta_id);
Expand Down Expand Up @@ -2230,7 +2233,7 @@ Status Tablet::_follow_cooldowned_data() {
to_add.push_back(std::move(rs));
}
// Note: We CANNOT call `modify_rowsets` here because `modify_rowsets` cannot process version graph correctly.
delete_rowsets(to_delete, false);
RETURN_IF_ERROR(delete_rowsets(to_delete, false));
add_rowsets(to_add);
// TODO(plat1ko): process primary key
_tablet_meta->set_cooldown_meta_id(cooldown_meta_pb.cooldown_meta_id());
Expand Down
2 changes: 1 addition & 1 deletion be/src/olap/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class Tablet final : public BaseTablet {
// MUST hold EXCLUSIVE `_meta_lock`
void add_rowsets(const std::vector<RowsetSharedPtr>& to_add);
// MUST hold EXCLUSIVE `_meta_lock`
void delete_rowsets(const std::vector<RowsetSharedPtr>& to_delete, bool move_to_stale);
Status delete_rowsets(const std::vector<RowsetSharedPtr>& to_delete, bool move_to_stale);

// MUST hold SHARED `_meta_lock`
const auto& rowset_map() const { return _rs_version_map; }
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/tablet_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include "olap/olap_common.h"
#include "olap/olap_define.h"
#include "olap/rowset/rowset.h"
#include "olap/rowset/rowset_meta_manager.h"
#include "olap/tablet_meta_manager.h"
#include "olap/utils.h"
#include "util/debug_points.h"
Expand Down

0 comments on commit 9096671

Please sign in to comment.