Skip to content

Commit 577567f

Browse files
committed
update
1 parent 41083ac commit 577567f

File tree

6 files changed

+31
-16
lines changed

6 files changed

+31
-16
lines changed

src/lib/homestore_backend/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,8 @@ add_test(NAME HomestoreTestGC COMMAND homestore_test_gc -csv error --executor im
169169
add_executable(homestore_test_scrubber)
170170
target_sources(homestore_test_scrubber PRIVATE $<TARGET_OBJECTS:homestore_tests_scrubber>)
171171
target_link_libraries(homestore_test_scrubber PUBLIC homeobject_homestore ${COMMON_TEST_DEPS})
172-
add_test(NAME HomestoreTestScrubber COMMAND homestore_test_scrubber -csv error --executor immediate --config_path ./
172+
add_test(NAME HomestoreTestScrubber COMMAND homestore_test_scrubber -csv error --executor immediate --config_path ./
173+
--override_config hs_backend_config.enable_scrubber=true
173174
--override_config nuraft_mesg_config.mesg_factory_config.data_request_deadline_secs:10)
174175

175176

src/lib/homestore_backend/hs_homeobject.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,19 @@ void HSHomeObject::init_homestore() {
259259
} else {
260260
LOGI("GC is disabled");
261261
}
262-
}
263262

264-
void HSHomeObject::on_replica_restart() {
265-
std::call_once(replica_restart_flag_, [this]() {
266-
// scrubber manager will be created and started only once here. we need make sure scrub manager is created and
267-
// started before pg is recovered, so that we a replica becomes leader of a pg, the scrub task can be resumed in
268-
// on_become_leader.
263+
// start scrubber
264+
if (HS_BACKEND_DYNAMIC_CONFIG(enable_scrubber)) {
265+
LOGI("Starting scrub manager");
269266
scrub_mgr_ = std::make_shared< ScrubManager >(this);
270267
scrub_mgr_->start();
268+
} else {
269+
LOGI("scrub manager is disabled");
270+
}
271+
}
271272

273+
void HSHomeObject::on_replica_restart() {
274+
std::call_once(replica_restart_flag_, [this]() {
272275
LOGI("Register PG, shard and gc related meta blk handlers");
273276
using namespace homestore;
274277
// recover PG
@@ -455,10 +458,10 @@ void HSHomeObject::shutdown() {
455458
// we need stop gc before shutting down homestore(where metaservice is shutdown), because gc mgr needs metaservice
456459
// to persist gc task metablk if there is any ongoing gc task. after stopping gc manager, there is no gc task
457460
// anymore, and thus now new gc task will be written to metaservice during homestore shutdown.
458-
gc_mgr_->stop();
461+
if (gc_mgr_) gc_mgr_->stop();
459462

460463
LOGI("stopping scrubbing");
461-
scrub_mgr_->stop();
464+
if (scrub_mgr_) scrub_mgr_->stop();
462465

463466
LOGI("start shutting down HomeStore");
464467
homestore::HomeStore::instance()->shutdown();

src/lib/homestore_backend/hs_homeobject_fbs/hs_backend_config.fbs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ table HSBackendSettings {
2323
//TODO: make this hotswap after gc is well tested
2424
enable_gc: bool = true;
2525

26+
//Enable scrubber
27+
//TODO: make this hotswap after scrubber is well tested
28+
enable_scrubber: bool = false;
29+
2630
//Total reserved chunk num (dedicated for gc/egc) per pdev
2731
reserved_chunk_num_per_pdev: uint8 = 6;
2832

src/lib/homestore_backend/hs_pg_manager.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,10 @@ void HSHomeObject::HS_PG::on_scrub_req_received(boost::intrusive_ptr< sisl::Gene
12171217
}
12181218

12191219
auto scrub_mgr = home_obj_.scrub_manager();
1220-
RELEASE_ASSERT(scrub_mgr, "ScrubManager is null in HS_PG::on_scrub_blob_req_received for pg={}", pg_id);
1220+
if (!scrub_mgr) {
1221+
LOGW("ScrubManager is not initialized in HS_PG::on_scrub_req_received for pg={}", pg_id);
1222+
return;
1223+
}
12211224
scrub_mgr->add_scrub_req(scrub_req);
12221225
}
12231226

@@ -1321,7 +1324,10 @@ void HSHomeObject::HS_PG::on_scrub_map_received(boost::intrusive_ptr< sisl::Gene
13211324
}
13221325

13231326
auto scrub_mgr = home_obj_.scrub_manager();
1324-
RELEASE_ASSERT(scrub_mgr, "ScrubManager is null in HS_PG::on_scrub_map_received for pg={}", pg_id);
1327+
if (!scrub_mgr) {
1328+
LOGW("ScrubManager is not initialized in HS_PG::on_scrub_map_received for pg={}", pg_id);
1329+
return;
1330+
}
13251331
scrub_mgr->add_scrub_map(pg_id, scrub_map);
13261332
}
13271333

src/lib/homestore_backend/replication_state_machine.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ void ReplicationStateMachine::on_destroy(const homestore::group_id_t& group_id)
291291
const auto pg_id = PG_ID.value();
292292
home_object_->pg_destroy(pg_id);
293293
LOGI("replica destroyed, cleared pg={} resources with group_id={}", pg_id, boost::uuids::to_string(group_id));
294-
295-
// we want the scrub_seq_num to keep the same when BR happens. so we only remove it from scrub manager when the
296-
// group is destroyed at this replica, so that BR will not delete/change the pg scrub superblk.
297-
298294
// there is a case that after pg is destroyed above and crash happends before scrub_mgr#remove_pg is called, there
299295
// will be a stale pg_scrub_superblk. we will handle this in metablk replay.
300296
home_object_->scrub_manager()->remove_pg(pg_id);
@@ -1064,6 +1060,7 @@ void ReplicationStateMachine::on_become_leader(const homestore::group_id_t& grou
10641060
}
10651061
const auto pg_id = pg_id_opt.value();
10661062
RELEASE_ASSERT(home_object_->pg_exists(pg_id), "pg={} should exist, but not! fatal error!", pg_id);
1063+
// TODO:: add whatever acitons needed to be take.
10671064
}
10681065

10691066
void ReplicationStateMachine::on_become_follower(const homestore::group_id_t& group_id) {
@@ -1076,7 +1073,7 @@ void ReplicationStateMachine::on_become_follower(const homestore::group_id_t& gr
10761073
RELEASE_ASSERT(home_object_->pg_exists(pg_id), "pg={} should exist, but not! fatal error!", pg_id);
10771074

10781075
LOGI("become follower of group {}, cancel scrub task for pg={}", group_id, pg_id);
1079-
// add whatever acitons needed to be take.
1076+
// TODO:: add whatever acitons needed to be take.
10801077

10811078
// cancel scrub task if I am not leader again.
10821079
home_object_->scrub_manager()->cancel_scrub_task(pg_id);

src/lib/homestore_backend/scrub_manager.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ void ScrubManager::start() {
271271

272272
void ScrubManager::stop() {
273273
m_scrub_task_queue.close();
274+
for (auto& [_, pg_scrub_ctx] : m_pg_scrub_ctx_map) {
275+
pg_scrub_ctx->cancel();
276+
}
277+
274278
if (m_scrub_timer_hdl == iomgr::null_timer_handle) {
275279
LOGINFOMOD(scrubmgr, "scrub scheduler timer is not running, no need to stop it");
276280
return;

0 commit comments

Comments
 (0)