@@ -252,8 +252,19 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob
252
252
data_bufs.emplace_back (aligned_buf);
253
253
254
254
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 (
256
266
sisl::round_up (aligned_buf->size (), homestore::data_service ().get_blk_size ()), hints, blk_id);
267
+ #endif
257
268
if (status != homestore::BlkAllocStatus::SUCCESS) {
258
269
LOGE (" Failed to allocate blocks for shardID=0x{:x}, pg={}, shard=0x{:x} blob {}" , ctx_->shard_cursor ,
259
270
(ctx_->shard_cursor >> homeobject::shard_width), (ctx_->shard_cursor & homeobject::shard_mask),
@@ -290,13 +301,15 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob
290
301
291
302
if (homestore::data_service ().commit_blk (blk_id) != homestore::BlkAllocStatus::SUCCESS) {
292
303
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 ();
293
305
return err;
294
306
}
295
307
// Add local blob info to index & PG
296
308
bool success =
297
309
home_obj_.local_add_blob_info (ctx_->pg_id , BlobInfo{ctx_->shard_cursor , blob_id, blk_id});
298
310
if (!success) {
299
311
LOGE (" Failed to add blob info for blob_id={}" , blob_id);
312
+ homestore::data_service ().async_free_blk (blk_id).get ();
300
313
return err;
301
314
}
302
315
@@ -313,7 +326,8 @@ int HSHomeObject::SnapshotReceiveHandler::process_blobs_snapshot_data(ResyncBlob
313
326
314
327
if (!all_io_submitted || ec != std::error_code{}) {
315
328
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 ());
317
331
} else {
318
332
LOGE (" Errors in writing this batch, code={}, message={}" , ec.value (), ec.message ());
319
333
}
0 commit comments