Skip to content

Commit

Permalink
[feat][store] Forbid diskann vector index split/merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
rock-git authored and ketor committed Nov 5, 2024
1 parent bf2e371 commit a676bd5
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/common/helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2210,4 +2210,11 @@ pb::common::Schema::Type Helper::TransformSchemaType(const std::string& name) {
return it->second;
}

bool Helper::IsSupportSplitAndMerge(const pb::common::RegionDefinition& definition) {
const auto& index_parameter = definition.index_parameter();
return index_parameter.index_type() != pb::common::IndexType::INDEX_TYPE_VECTOR ||
index_parameter.vector_index_parameter().vector_index_type() !=
pb::common::VectorIndexType::VECTOR_INDEX_TYPE_DISKANN;
}

} // namespace dingodb
2 changes: 2 additions & 0 deletions src/common/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,8 @@ class Helper {
static std::string ConvertColumnValueToString(const pb::meta::ColumnDefinition& column_definition,
const std::any& value);
static pb::common::Schema::Type TransformSchemaType(const std::string& name);

static bool IsSupportSplitAndMerge(const pb::common::RegionDefinition& definition);
};

} // namespace dingodb
Expand Down
9 changes: 9 additions & 0 deletions src/coordinator/coordinator_control_coor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2615,6 +2615,11 @@ butil::Status CoordinatorControl::SplitRegionWithTaskList(int64_t split_from_reg
DINGO_LOG(ERROR) << "SplitRegion from region not exists, id = " << split_from_region_id;
return butil::Status(pb::error::Errno::EREGION_NOT_FOUND, "SplitRegion from region not exists");
}

if (!Helper::IsSupportSplitAndMerge(split_from_region.definition())) {
return butil::Status(pb::error::Errno::ENOT_SUPPORT, "Region not support split");
}

if (split_from_region.definition().store_engine() == pb::common::STORE_ENG_MONO_STORE &&
!FLAGS_enable_region_split_and_merge_for_lite) {
DINGO_LOG(ERROR) << "SplitRegion region =" << split_from_region_id << " disable split ";
Expand Down Expand Up @@ -2799,6 +2804,10 @@ butil::Status CoordinatorControl::MergeRegionWithTaskList(int64_t merge_from_reg
return butil::Status(pb::error::Errno::EREGION_NOT_FOUND, "MergeRegion from region not exists");
}

if (!Helper::IsSupportSplitAndMerge(merge_from_region.definition())) {
return butil::Status(pb::error::Errno::ENOT_SUPPORT, "Region not support merge");
}

// validate merge_to_region_id
pb::coordinator_internal::RegionInternal merge_to_region;
ret = region_map_.Get(merge_to_region_id, merge_to_region);
Expand Down
6 changes: 6 additions & 0 deletions src/meta/store_meta_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ void Region::SetNeedBootstrapDoSnapshot(bool need_do_snapshot) {
inner_region_.set_need_bootstrap_do_snapshot(need_do_snapshot);
}

bool Region::IsSupportSplitAndMerge() {
BAIDU_SCOPED_LOCK(mutex_);

return Helper::IsSupportSplitAndMerge(inner_region_.definition());
}

bool Region::DisableChange() {
BAIDU_SCOPED_LOCK(mutex_);
return inner_region_.disable_change();
Expand Down
2 changes: 2 additions & 0 deletions src/meta/store_meta_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class Region {
bool NeedBootstrapDoSnapshot();
void SetNeedBootstrapDoSnapshot(bool need_do_snapshot);

bool IsSupportSplitAndMerge();

bool DisableChange();
void SetDisableChange(bool disable_change);

Expand Down
4 changes: 4 additions & 0 deletions src/split/split_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ void PreSplitCheckTask::PreSplitCheck() {
auto regions = GET_STORE_REGION_META->GetAllAliveRegion();
int64_t split_check_approximate_size = ConfigHelper::GetSplitCheckApproximateSize();
for (auto& region : regions) {
if (!region->IsSupportSplitAndMerge()) {
continue;
}

auto region_metric = metrics->GetMetrics(region->Id());
bool need_scan_check = true;
std::string reason;
Expand Down
10 changes: 10 additions & 0 deletions src/store/region_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,10 @@ butil::Status SplitRegionTask::ValidateSplitRegion(std::shared_ptr<StoreRegionMe
return butil::Status(pb::error::EREGION_NOT_FOUND, "Parent region not exist.");
}

if (!parent_region->IsSupportSplitAndMerge()) {
return butil::Status(pb::error::ENOT_SUPPORT, "Region not support split.");
}

if (parent_region->DisableChange()) {
return butil::Status(pb::error::EREGION_DISABLE_CHANGE, "Disable region change.");
}
Expand Down Expand Up @@ -652,11 +656,17 @@ butil::Status MergeRegionTask::ValidateMergeRegion(std::shared_ptr<StoreRegionMe
if (source_region == nullptr) {
return butil::Status(pb::error::EREGION_NOT_FOUND, "Not found source region");
}
if (!source_region->IsSupportSplitAndMerge()) {
return butil::Status(pb::error::ENOT_SUPPORT, "Region not support merge.");
}

auto target_region = store_region_meta->GetRegion(merge_request.target_region_id());
if (target_region == nullptr) {
return butil::Status(pb::error::EREGION_NOT_FOUND, "Not found target region");
}
if (!target_region->IsSupportSplitAndMerge()) {
return butil::Status(pb::error::ENOT_SUPPORT, "Region not support merge.");
}

if (source_region->TemporaryDisableChange()) {
return butil::Status(pb::error::EREGION_DISABLE_CHANGE, "Temporary disable source region change.");
Expand Down

0 comments on commit a676bd5

Please sign in to comment.