Skip to content

Commit f6287c4

Browse files
committed
address comment
Signed-off-by: Xiaoxi Chen <[email protected]>
1 parent 1129a77 commit f6287c4

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/lib/homestore_backend/snapshot_receive_handler.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,19 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob
252252
data_bufs.emplace_back(aligned_buf);
253253

254254
homestore::MultiBlkId blk_id;
255-
auto status = homestore::data_service().alloc_blks(
255+
homestore::BlkAllocStatus status;
256+
#ifdef _PRERELEASE
257+
if (iomgr_flip::instance()->test_flip("snapshot_receiver_blk_allocation_error")) {
258+
LOGW("Simulating blob snapshot allocation error");
259+
status = homestore::BlkAllocStatus::SPACE_FULL
260+
} else {
261+
status = homestore::data_service().alloc_blks(
262+
sisl::round_up(aligned_buf->size(), homestore::data_service().get_blk_size()), hints, blk_id);
263+
}
264+
#else
265+
status = homestore::data_service().alloc_blks(
256266
sisl::round_up(aligned_buf->size(), homestore::data_service().get_blk_size()), hints, blk_id);
267+
#endif
257268
if (status != homestore::BlkAllocStatus::SUCCESS) {
258269
LOGE("Failed to allocate blocks for shardID=0x{:x}, pg={}, shard=0x{:x} blob {}", ctx_->shard_cursor,
259270
(ctx_->shard_cursor >> homeobject::shard_width), (ctx_->shard_cursor & homeobject::shard_mask),
@@ -290,13 +301,15 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob
290301

291302
if (homestore::data_service().commit_blk(blk_id) != homestore::BlkAllocStatus::SUCCESS) {
292303
LOGE("Failed to commit blk_id={} for blob_id={}", blk_id.to_string(), blob_id);
304+
homestore::data_service().async_free_blk(blk_id).get();
293305
return err;
294306
}
295307
// Add local blob info to index & PG
296308
bool success =
297309
home_obj_.local_add_blob_info(ctx_->pg_id, BlobInfo{ctx_->shard_cursor, blob_id, blk_id});
298310
if (!success) {
299311
LOGE("Failed to add blob info for blob_id={}", blob_id);
312+
homestore::data_service().async_free_blk(blk_id).get();
300313
return err;
301314
}
302315

@@ -313,7 +326,8 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob
313326

314327
if (!all_io_submitted || ec != std::error_code{}) {
315328
if (!all_io_submitted) {
316-
LOGE("Errors in submitting the batch, expect {} blobs, submitted {}.", data_blobs.blob_list()->size(), futs.size());
329+
LOGE("Errors in submitting the batch, expect {} blobs, submitted {}.", data_blobs.blob_list()->size(),
330+
futs.size());
317331
} else {
318332
LOGE("Errors in writing this batch, code={}, message={}", ec.value(), ec.message());
319333
}

src/lib/homestore_backend/tests/test_homestore_backend_dynamic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ TEST_F(HomeObjectFixture, ReplaceMember) {
9090
set_basic_flip("snapshot_receiver_pg_error", 1); // simulate pg creation error
9191
set_basic_flip("snapshot_receiver_shard_write_data_error", 2, 33); // simulate shard write data error
9292
set_basic_flip("snapshot_receiver_blob_write_data_error", 4, 15); // simulate blob write data error
93+
set_basic_flip("snapshot_receiver_blk_allocation_error", 4, 15); // simulate blob allocation error
9394
#endif
9495

9596
run_on_pg_leader(pg_id, [&]() {

0 commit comments

Comments
 (0)