Skip to content

Commit f604993

Browse files
SDSTOR-21989: check index_table existence before using it (#409)
1 parent 2de356a commit f604993

3 files changed

Lines changed: 28 additions & 10 deletions

File tree

conanfile.py

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

1111
class HomeObjectConan(ConanFile):
1212
name = "homeobject"
13-
version = "4.1.11"
13+
version = "4.1.12"
1414

1515
homepage = "https://github.com/eBay/HomeObject"
1616
description = "Blob Store built on HomeStore"

src/lib/homestore_backend/hs_blob_manager.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ BlobManager::AsyncResult< blob_id_t > HSHomeObject::_put_blob(ShardInfo const& s
8888
return folly::makeUnexpected(BlobErrorCode::SHUTTING_DOWN);
8989
}
9090
incr_pending_request_num();
91-
// check user key size
91+
// check user key size
9292
if (blob.user_key.size() > BlobHeader::max_user_key_length) {
9393
BLOGE(tid, shard.id, 0, "input user key length > max_user_key_length {}", blob.user_key.size(),
9494
BlobHeader::max_user_key_length);
@@ -167,8 +167,7 @@ BlobManager::AsyncResult< blob_id_t > HSHomeObject::_put_blob(ShardInfo const& s
167167

168168
// Set offset of actual data after the blob header and user key (rounded off)
169169
req->blob_header()->data_offset = req->blob_header_buf().size();
170-
RELEASE_ASSERT(req->blob_header()->data_offset == _data_block_size,
171-
"blob header should equals _data_block_size");
170+
RELEASE_ASSERT(req->blob_header()->data_offset == _data_block_size, "blob header should equals _data_block_size");
172171
// In case blob body is not aligned, create a new aligned buffer and copy the blob body.
173172
if (((r_cast< uintptr_t >(blob.body.cbytes()) % io_align) != 0) || ((blob_size % io_align) != 0)) {
174173
// If address or size is not aligned, create a separate aligned buffer and do expensive memcpy.
@@ -367,9 +366,7 @@ BlobManager::AsyncResult< Blob > HSHomeObject::_get_blob_data(const shared< home
367366
}
368367

369368
auto verify_result = do_verify_blob(read_buf.cbytes(), shard_id, 0 /* no blob_id check */);
370-
if (!verify_result.hasValue()) {
371-
return folly::makeUnexpected(verify_result.error());
372-
}
369+
if (!verify_result.hasValue()) { return folly::makeUnexpected(verify_result.error()); }
373370
std::string user_key = std::move(verify_result.value());
374371

375372
BlobHeader const* header = r_cast< BlobHeader const* >(read_buf.cbytes());
@@ -498,8 +495,14 @@ HSHomeObject::blob_put_get_blk_alloc_hints(sisl::blob const& header, cintrusive<
498495
hs_shard->sb_->p_chunk_id, get_reserved_blks());
499496

500497
if (msg_header->blob_id != 0) {
498+
auto pg_index_table = hs_pg->index_table_;
499+
if (!pg_index_table) {
500+
LOGW("index table is not found for pg={}, skip statistics refresh", msg_header->pg_id);
501+
return folly::makeUnexpected(homestore::ReplServiceError::RESULT_NOT_EXIST_YET);
502+
}
503+
501504
// check if the blob already exists, if yes, return the blk id
502-
auto r = get_blob_from_index_table(hs_pg->index_table_, msg_header->shard_id, msg_header->blob_id);
505+
auto r = get_blob_from_index_table(pg_index_table, msg_header->shard_id, msg_header->blob_id);
503506
if (r.hasValue()) {
504507
BLOGT(tid, msg_header->shard_id, msg_header->blob_id,
505508
"Blob has already been persisted, blk_num={}, blk_count={}", r.value().blk_num(),

src/lib/homestore_backend/hs_pg_manager.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,6 +1214,12 @@ uint32_t HSHomeObject::get_pg_tombstone_blob_count(pg_id_t pg_id) const {
12141214
return 0;
12151215
}
12161216

1217+
auto pg_index_table = hs_pg->index_table_;
1218+
if (!pg_index_table) {
1219+
LOGE("index table is not found for pg={}, skip statistics refresh", pg_id);
1220+
return 0;
1221+
}
1222+
12171223
uint32_t tombstone_blob_count{0};
12181224

12191225
auto start_key =
@@ -1234,7 +1240,7 @@ uint32_t HSHomeObject::get_pg_tombstone_blob_count(pg_id_t pg_id) const {
12341240

12351241
std::vector< std::pair< BlobRouteKey, BlobRouteValue > > valid_blob_indexes;
12361242

1237-
auto const status = hs_pg->index_table_->query(query_req, valid_blob_indexes);
1243+
auto const status = pg_index_table->query(query_req, valid_blob_indexes);
12381244
if (status != homestore::btree_status_t::success && status != homestore::btree_status_t::has_more) {
12391245
LOGERROR("Failed to query blobs in index table for pg={}", pg_id);
12401246
return 0;
@@ -1249,6 +1255,15 @@ uint32_t HSHomeObject::get_pg_tombstone_blob_count(pg_id_t pg_id) const {
12491255
void HSHomeObject::refresh_pg_statistics(pg_id_t pg_id) {
12501256
auto hs_pg = const_cast< HS_PG* >(_get_hs_pg_unlocked(pg_id));
12511257
RELEASE_ASSERT(hs_pg, "Failed to get pg={} for statistics refresh", pg_id);
1258+
auto pg_index_table = hs_pg->index_table_;
1259+
if (!pg_index_table) {
1260+
if (hs_pg->pg_sb_->state == PGState::DESTROYED) {
1261+
LOGI("pg={} is destroyed, skip statistics refresh", pg_id);
1262+
} else {
1263+
RELEASE_ASSERT(false, "index table is not found for pg={} and not in PGState::DESTROYED state", pg_id);
1264+
}
1265+
return;
1266+
}
12521267

12531268
// Step 1: Scan index table to count active and tombstone blobs in one pass
12541269
uint64_t active_count = 0;
@@ -1276,7 +1291,7 @@ void HSHomeObject::refresh_pg_statistics(pg_id_t pg_id) {
12761291
}};
12771292

12781293
std::vector< std::pair< BlobRouteKey, BlobRouteValue > > dummy_out;
1279-
auto ret = hs_pg->index_table_->query(query_req, dummy_out);
1294+
auto ret = pg_index_table->query(query_req, dummy_out);
12801295
RELEASE_ASSERT(ret == homestore::btree_status_t::success, "Failed to scan index table for pg={}, status={}", pg_id,
12811296
ret);
12821297

0 commit comments

Comments
 (0)