diff --git a/db/blob/blob_file_reader.cc b/db/blob/blob_file_reader.cc index 9ce0b5b89..0cb49ae62 100644 --- a/db/blob/blob_file_reader.cc +++ b/db/blob/blob_file_reader.cc @@ -358,11 +358,18 @@ void BlobFileReader::MultiGetBlob( const autovector& value_sizes, autovector& statuses, autovector& values, uint64_t* bytes_read) const { const size_t num_blobs = user_keys.size(); + assert(num_blobs > 0); assert(num_blobs == offsets.size()); assert(num_blobs == value_sizes.size()); assert(num_blobs == statuses.size()); assert(num_blobs == values.size()); +#ifndef NDEBUG + for (size_t i = 0; i < offsets.size() - 1; ++i) { + assert(offsets[i] <= offsets[i + 1]); + } +#endif // !NDEBUG + std::vector read_reqs(num_blobs); autovector adjustments; uint64_t total_len = 0; diff --git a/db/blob/blob_file_reader.h b/db/blob/blob_file_reader.h index 06087c3a0..b7da393f3 100644 --- a/db/blob/blob_file_reader.h +++ b/db/blob/blob_file_reader.h @@ -44,6 +44,7 @@ class BlobFileReader { CompressionType compression_type, PinnableSlice* value, uint64_t* bytes_read) const; + // offsets must be sorted in ascending order by caller. void MultiGetBlob( const ReadOptions& read_options, const autovector>& user_keys, diff --git a/file/random_access_file_reader.cc b/file/random_access_file_reader.cc index dd0392609..489167719 100644 --- a/file/random_access_file_reader.cc +++ b/file/random_access_file_reader.cc @@ -224,6 +224,12 @@ IOStatus RandomAccessFileReader::MultiRead(const IOOptions& opts, (void)aligned_buf; // suppress warning of unused variable in LITE mode assert(num_reqs > 0); +#ifndef NDEBUG + for (size_t i = 0; i < num_reqs - 1; ++i) { + assert(read_reqs[i].offset <= read_reqs[i + 1].offset); + } +#endif // !NDEBUG + // To be paranoid modify scratch a little bit, so in case underlying // FileSystem doesn't fill the buffer but return succee and `scratch` returns // contains a previous block, returned value will not pass checksum.