Skip to content

Commit

Permalink
Merge branch 'main' into baseline_main
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwmao committed Dec 9, 2024
2 parents fd8e51f + c8cbe36 commit 55efbde
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class HomeObjectConan(ConanFile):
name = "homeobject"
version = "2.1.15"
version = "2.1.17"

homepage = "https://github.com/eBay/HomeObject"
description = "Blob Store built on HomeReplication"
Expand Down
12 changes: 12 additions & 0 deletions src/lib/homestore_backend/heap_chunk_selector.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,18 @@ class HeapChunkSelector : public homestore::ChunkSelector {

uint32_t get_chunk_size() const;

/**
* @brief Returns the number of disks we seen
*
* Warning : calling this before HS fully start might getting wrong result.
*
* This function returns the number of disks the chunk selector seen.
* It should be the accurate source that how many disks in the system for data.
* If a disk is down in degraded mode, it wont be load and no chunk will be
* added into selector.
*/
uint32_t total_disks() const { return m_per_dev_heap.size(); }

private:
void add_chunk_internal(const chunk_num_t, bool add_to_heap = true);

Expand Down
10 changes: 8 additions & 2 deletions src/lib/homestore_backend/hs_homeobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class HSReplApplication : public homestore::ReplApplication {
return it->second;
}

void on_repl_devs_init_completed() override {
_home_object->on_replica_restart();
}

std::pair< std::string, uint16_t > lookup_peer(homestore::replica_id_t uuid) const override {
std::string endpoint;
// for folly::uri to parse correctly, we need to add "http://" prefix
Expand Down Expand Up @@ -195,13 +199,14 @@ void HSHomeObject::init_homestore() {
.chunk_sel_type = chunk_selector_type_t::CUSTOM}},
});
}

// We dont have any repl dev now, explicitly call init_completed_cb() where we register PG/Shard meta types.
repl_app->on_repl_devs_init_completed();
// Create a superblock that contains our SvcId
auto svc_sb = homestore::superblk< svc_info_superblk_t >(_svc_meta_name);
svc_sb.create(sizeof(svc_info_superblk_t));
svc_sb->svc_id_ = _our_id;
svc_sb.write();
on_replica_restart();

} else {
RELEASE_ASSERT(!_our_id.is_nil(), "No SvcId read after HomeStore recovery!");
auto const new_id = app->discover_svcid(_our_id);
Expand Down Expand Up @@ -313,6 +318,7 @@ HomeObjectStats HSHomeObject::_get_stats() const {

stats.num_open_shards = num_open_shards;
stats.avail_open_shards = chunk_selector()->total_chunks() - num_open_shards;
stats.num_disks = chunk_selector()->total_disks();
return stats;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/homestore_backend/replication_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void ReplicationStateMachine::on_rollback(int64_t lsn, sisl::blob const& header,
}
}

void ReplicationStateMachine::on_restart() { home_object_->on_replica_restart(); }
void ReplicationStateMachine::on_restart() { LOGD("ReplicationStateMachine::on_restart");}

void ReplicationStateMachine::on_error(ReplServiceError error, const sisl::blob& header, const sisl::blob& key,
cintrusive< repl_req_ctx >& ctx) {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/homestore_backend/tests/test_heap_chunk_selector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ TEST_F(HeapChunkSelectorTest, test_for_each_chunk) {
ASSERT_EQ(size.load(), 18);
}

TEST_F(HeapChunkSelectorTest, test_total_disks) { ASSERT_EQ(HCS.total_disks(), 3); }

TEST_F(HeapChunkSelectorTest, test_identical_layout) {
const homestore::blk_count_t count = 1;
homestore::blk_alloc_hints hints;
Expand Down

0 comments on commit 55efbde

Please sign in to comment.