From: anand76 Date: Thu, 28 Mar 2024 20:56:28 +0000 (-0700) Subject: Don't swallow errors in BlockBasedTable::MultiGet (#12486) X-Git-Tag: v9.1.0~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6d01f0f6e31a8be6a52592760345557e980a270;p=rocksdb.git Don't swallow errors in BlockBasedTable::MultiGet (#12486) Summary: Errors were being swallowed in `BlockBasedTable::MultiGet` under some circumstances, such as error when parsing the internal key from the block, or IO error when reading the blob value. We need to set the status for the key to the observed error. Pull Request resolved: https://github.com/facebook/rocksdb/pull/12486 Test Plan: Run db_stress and verify the expected error failure before, and no failures after the change. Reviewed By: jaykorean, ajkr Differential Revision: D55483940 Pulled By: anand1976 fbshipit-source-id: 493e44db507d5db45e8d1ef2e67808d2c4046318 --- diff --git a/table/block_based/block_based_table_reader_sync_and_async.h b/table/block_based/block_based_table_reader_sync_and_async.h index 6350560c1..30d9884ec 100644 --- a/table/block_based/block_based_table_reader_sync_and_async.h +++ b/table/block_based/block_based_table_reader_sync_and_async.h @@ -729,7 +729,7 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::MultiGet) } // Call the *saver function on each entry/block until it returns false - for (; biter->Valid(); biter->Next()) { + for (; biter->status().ok() && biter->Valid(); biter->Next()) { ParsedInternalKey parsed_key; Status pik_status = ParseInternalKey( biter->key(), &parsed_key, false /* log_err_key */); // TODO @@ -754,9 +754,6 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::MultiGet) done = true; break; } - if (s.ok()) { - s = biter->status(); - } } // Write the block cache access. // XXX: There appear to be 'break' statements above that bypass this @@ -779,8 +776,10 @@ DEFINE_SYNC_AND_ASYNC(void, BlockBasedTable::MultiGet) *lookup_data_block_context, lookup_data_block_context->block_key, referenced_key, does_referenced_key_exist, referenced_data_size); } - s = biter->status(); - if (done) { + if (s.ok()) { + s = biter->status(); + } + if (done || !s.ok()) { // Avoid the extra Next which is expensive in two-level indexes break; }