From e4fa26f60a459e859cb16850c00f8cdcf217eb45 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 22 Oct 2023 16:45:59 +0300 Subject: [PATCH] Do not call stop_updating after failed write_new_block and after clear_block (both delete the item) --- src/kv_db.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/kv_db.cpp b/src/kv_db.cpp index 062acb4f..b10c9b05 100644 --- a/src/kv_db.cpp +++ b/src/kv_db.cpp @@ -1433,7 +1433,6 @@ void kv_op_t::update_block(int path_pos, bool is_delete, const std::string & key if (res < 0) { blk->cancel_change(); - db->stop_updating(right_blk); db->stop_updating(blk); cb(res); return; @@ -1448,7 +1447,7 @@ void kv_op_t::update_block(int path_pos, bool is_delete, const std::string & key if (res < 0) { blk->cancel_change(); - db->stop_updating(left_blk); + db->stop_updating(right_blk); db->stop_updating(blk); cb(res); return; @@ -1472,12 +1471,10 @@ void kv_op_t::update_block(int path_pos, bool is_delete, const std::string & key db->stop_updating(blk); clear_block(db, left_blk, 0, [=, left_offset = left_blk->offset](int res) { - db->stop_updating(left_blk); if (res < 0) fprintf(stderr, "Failed to clear unreferenced block %lu: %s (code %d)\n", left_offset, strerror(-res), res); clear_block(db, right_blk, 0, [=, right_offset = right_blk->offset](int res) { - db->stop_updating(right_blk); if (res < 0) fprintf(stderr, "Failed to clear unreferenced block %lu: %s (code %d)\n", right_offset, strerror(-res), res); // CAS failure - zero garbage left_blk and right_blk and retry from the beginning @@ -1531,7 +1528,6 @@ void kv_op_t::update_block(int path_pos, bool is_delete, const std::string & key { clear_block(db, right_blk, 0, [=, right_offset = right_blk->offset](int res) { - db->stop_updating(right_blk); if (res < 0) fprintf(stderr, "Failed to clear unreferenced block %lu: %s (code %d)\n", right_offset, strerror(-res), res); // CAS failure - zero garbage right_blk and retry from the beginning