Skip to content

Commit a4b1a86

Browse files
authored
Issue: avoid log reply for graceful restart (#146)
* Issue: avoid log reply for graceful restart
1 parent 44eb93c commit a4b1a86

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class HomeBlocksConan(ConanFile):
1111
name = "homeblocks"
12-
version = "5.0.0"
12+
version = "5.0.2"
1313

1414
homepage = "https://github.com/eBay/HomeBlocks"
1515
description = "Block Store built on HomeStore"

src/lib/homeblks_impl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ void HomeBlocksImpl::on_hb_meta_blk_found(sisl::byte_view const& buf, void* cook
422422
if (sb_->test_flag(SB_FLAGS_GRACEFUL_SHUTDOWN)) {
423423
// if it is a gracefuln shutdown, this flag should be set again in shutdown routine;
424424
sb_->clear_flag(SB_FLAGS_GRACEFUL_SHUTDOWN);
425+
gracefully_shutdown_ = true;
425426
LOGI("System was shutdown gracefully");
426427
} else if (sb_->test_flag(SB_FLAGS_RESTRICTED)) {
427428
is_restricted_.store(true);

src/lib/homeblks_impl.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab
7878
std::unordered_map< std::string, shared< VolumeIndexTable > > idx_tbl_map_;
7979

8080
bool recovery_done_{false};
81+
bool gracefully_shutdown_{false};
8182
std::mutex sb_lock_; // this lock is only used when FC is triggered;
8283
superblk< homeblks_sb_t > sb_;
8384
peer_id_t our_uuid_;
@@ -161,6 +162,7 @@ class HomeBlocksImpl : public HomeBlocks, public VolumeManager, public std::enab
161162
void exit_fc(VolumePtr& vol);
162163
bool is_restricted() const { return is_restricted_.load(); }
163164
hs_chunk_size_cfg_t get_chunk_size() const;
165+
bool is_graceful_shutdown() const { return gracefully_shutdown_; }
164166

165167
public:
166168
// public static APIs;

src/lib/volume_mgr.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ void HomeBlocksImpl::submit_io_batch() { homestore::data_service().submit_io_bat
313313
void HomeBlocksImpl::on_write(int64_t lsn, const sisl::blob& header, const sisl::blob& key,
314314
const std::vector< homestore::MultiBlkId >& new_blkids,
315315
cintrusive< homestore::repl_req_ctx >& ctx) {
316+
317+
// We are not expecting log reply for a graceful restart;
318+
// if we are in recovery path, we must be recovering from a crash.
319+
DEBUG_ASSERT(ctx != nullptr || !is_graceful_shutdown(),
320+
"repl ctx is null (recovery path) in graceful shutdown scenario, this is not expected!");
321+
316322
repl_result_ctx< VolumeManager::NullResult >* repl_ctx{nullptr};
317323
if (ctx) { repl_ctx = boost::static_pointer_cast< repl_result_ctx< VolumeManager::NullResult > >(ctx).get(); }
318324
auto msg_header = r_cast< MsgHeader* >(const_cast< uint8_t* >(header.cbytes()));

0 commit comments

Comments
 (0)