diff --git a/conf/nebula-storaged.conf.default b/conf/nebula-storaged.conf.default index eef25b7f8..5b61c7e4c 100644 --- a/conf/nebula-storaged.conf.default +++ b/conf/nebula-storaged.conf.default @@ -104,3 +104,5 @@ ############## Runtime global Options ############## # Index rebuild batch number --rebuild_index_batch_num=256 +# Index rebuild processing interval, microsecond. +--rebuild_index_process_interval=30000 diff --git a/conf/nebula-storaged.conf.production b/conf/nebula-storaged.conf.production index 2c09907a8..380e59379 100644 --- a/conf/nebula-storaged.conf.production +++ b/conf/nebula-storaged.conf.production @@ -105,3 +105,5 @@ ############## Runtime global Options ############## # Index rebuild batch number --rebuild_index_batch_num=256 +# Index rebuild processing interval, microsecond. +--rebuild_index_process_interval=30000 diff --git a/src/storage/StorageFlags.cpp b/src/storage/StorageFlags.cpp index e2a0bb9bb..6671e1530 100644 --- a/src/storage/StorageFlags.cpp +++ b/src/storage/StorageFlags.cpp @@ -26,6 +26,9 @@ DEFINE_int32(rebuild_index_batch_num, 256, DEFINE_int32(rebuild_index_locked_threshold, 256, "The locked threshold will refuse writing."); +DEFINE_int32(rebuild_index_process_interval, 30000, + "Index rebuild processing interval, microsecond."); + DEFINE_bool(enable_vertex_cache, true, "Enable vertex cache"); DEFINE_int32(reader_handlers, 32, "Total reader handlers"); diff --git a/src/storage/StorageFlags.h b/src/storage/StorageFlags.h index 456a19943..48936acea 100644 --- a/src/storage/StorageFlags.h +++ b/src/storage/StorageFlags.h @@ -23,6 +23,8 @@ DECLARE_int32(rebuild_index_batch_num); DECLARE_int32(rebuild_index_locked_threshold); +DECLARE_int32(rebuild_index_process_interval); + DECLARE_bool(enable_vertex_cache); DECLARE_int32(reader_handlers); diff --git a/src/storage/admin/RebuildEdgeIndexTask.cpp b/src/storage/admin/RebuildEdgeIndexTask.cpp index 9e3241d7f..42a4444d8 100644 --- a/src/storage/admin/RebuildEdgeIndexTask.cpp +++ b/src/storage/admin/RebuildEdgeIndexTask.cpp @@ -157,6 +157,7 @@ RebuildEdgeIndexTask::buildIndexGlobal(GraphSpaceID space, } } iter->next(); + usleep(FLAGS_rebuild_index_process_interval); } auto result = writeData(space, part, std::move(data)); diff --git a/src/storage/admin/RebuildIndexTask.cpp b/src/storage/admin/RebuildIndexTask.cpp index 57000ba2e..7a695e12b 100644 --- a/src/storage/admin/RebuildIndexTask.cpp +++ b/src/storage/admin/RebuildIndexTask.cpp @@ -160,6 +160,7 @@ RebuildIndexTask::buildIndexOnOperations(GraphSpaceID space, PartitionID part) { operations.clear(); } operationIter->next(); + usleep(FLAGS_rebuild_index_process_interval); } auto ret = cleanupOperationLogs(space, part, operations); @@ -224,6 +225,7 @@ RebuildIndexTask::removeLegacyLogs(GraphSpaceID space, operations.clear(); } operationIter->next(); + usleep(FLAGS_rebuild_index_process_interval); } return nebula::cpp2::ErrorCode::SUCCEEDED; diff --git a/src/storage/admin/RebuildTagIndexTask.cpp b/src/storage/admin/RebuildTagIndexTask.cpp index 9fa6dcec2..053ec0655 100644 --- a/src/storage/admin/RebuildTagIndexTask.cpp +++ b/src/storage/admin/RebuildTagIndexTask.cpp @@ -140,6 +140,7 @@ RebuildTagIndexTask::buildIndexGlobal(GraphSpaceID space, } } iter->next(); + usleep(FLAGS_rebuild_index_process_interval); } auto result = writeData(space, part, std::move(data)); diff --git a/src/storage/test/RebuildIndexTest.cpp b/src/storage/test/RebuildIndexTest.cpp index 51e8fdadf..8a76ef7c2 100644 --- a/src/storage/test/RebuildIndexTest.cpp +++ b/src/storage/test/RebuildIndexTest.cpp @@ -26,6 +26,7 @@ class RebuildIndexTest : public ::testing::Test { static void SetUpTestCase() { LOG(INFO) << "SetUp RebuildIndexTest TestCase"; FLAGS_rebuild_index_locked_threshold = 1; + FLAGS_rebuild_index_process_interval = 0; rootPath_ = std::make_unique("/tmp/RebuildIndexTest.XXXXXX"); cluster_ = std::make_unique(); cluster_->initStorageKV(rootPath_->path());