Skip to content

Commit

Permalink
[NO COMMIT] Validate usage of allow_refresh=false
Browse files Browse the repository at this point in the history
  • Loading branch information
pdillinger committed Feb 4, 2025
1 parent a10b4aa commit 20dea55
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions db/arena_wrapped_db_iter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void ArenaWrappedDBIter::Init(
cfh, expose_blob_index);

sv_number_ = version_number;
assert(allow_refresh || gAllowFalseAllowRefresh);
allow_refresh_ = allow_refresh;
memtable_range_tombstone_iter_ = nullptr;
}
Expand Down
3 changes: 3 additions & 0 deletions db/db_impl/db_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@

namespace ROCKSDB_NAMESPACE {

// XXX: debug only
thread_local bool gAllowFalseAllowRefresh = false;

const std::string kDefaultColumnFamilyName("default");
const std::string kPersistentStatsColumnFamilyName(
"___rocksdb_stats_history___");
Expand Down
2 changes: 2 additions & 0 deletions db/db_impl/db_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@

namespace ROCKSDB_NAMESPACE {

extern thread_local bool gAllowFalseAllowRefresh;

class Arena;
class ArenaWrappedDBIter;
class InMemoryStatsHistoryIterator;
Expand Down
2 changes: 2 additions & 0 deletions table/sst_file_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "table/table_builder.h"
#include "table/table_iterator.h"
#include "table/table_reader.h"
#include "util/defer.h"

namespace ROCKSDB_NAMESPACE {

Expand Down Expand Up @@ -86,6 +87,7 @@ Iterator* SstFileReader::NewIterator(const ReadOptions& roptions) {
auto sequence = roptions.snapshot != nullptr
? roptions.snapshot->GetSequenceNumber()
: kMaxSequenceNumber;
SaveAndRestore<bool> ovr(&gAllowFalseAllowRefresh, true);
ArenaWrappedDBIter* res = new ArenaWrappedDBIter();
res->Init(
r->options.env, roptions, r->ioptions, r->moptions, nullptr /* version */,
Expand Down
3 changes: 3 additions & 0 deletions utilities/transactions/write_prepared_txn_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "rocksdb/utilities/transaction_db.h"
#include "test_util/sync_point.h"
#include "util/cast_util.h"
#include "util/defer.h"
#include "util/mutexlock.h"
#include "util/string_util.h"
#include "utilities/transactions/pessimistic_transaction.h"
Expand Down Expand Up @@ -401,6 +402,7 @@ Iterator* WritePreparedTxnDB::NewIterator(const ReadOptions& _read_options,
read_options.io_activity = Env::IOActivity::kDBIterator;
}
constexpr bool expose_blob_index = false;
SaveAndRestore<bool> ovr(&gAllowFalseAllowRefresh, true);
constexpr bool allow_refresh = false;
std::shared_ptr<ManagedSnapshot> own_snapshot = nullptr;
SequenceNumber snapshot_seq = kMaxSequenceNumber;
Expand Down Expand Up @@ -448,6 +450,7 @@ Status WritePreparedTxnDB::NewIterators(
read_options.io_activity = Env::IOActivity::kDBIterator;
}
constexpr bool expose_blob_index = false;
SaveAndRestore<bool> ovr(&gAllowFalseAllowRefresh, true);
constexpr bool allow_refresh = false;
std::shared_ptr<ManagedSnapshot> own_snapshot = nullptr;
SequenceNumber snapshot_seq = kMaxSequenceNumber;
Expand Down
2 changes: 2 additions & 0 deletions utilities/transactions/write_unprepared_txn_db.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "db/arena_wrapped_db_iter.h"
#include "rocksdb/utilities/transaction_db.h"
#include "util/cast_util.h"
#include "util/defer.h"

namespace ROCKSDB_NAMESPACE {

Expand Down Expand Up @@ -403,6 +404,7 @@ Iterator* WriteUnpreparedTxnDB::NewIterator(const ReadOptions& _read_options,
}
// TODO(lth): Refactor so that this logic is shared with WritePrepared.
constexpr bool expose_blob_index = false;
SaveAndRestore<bool> ovr(&gAllowFalseAllowRefresh, true);
constexpr bool allow_refresh = false;
std::shared_ptr<ManagedSnapshot> own_snapshot = nullptr;
SequenceNumber snapshot_seq = kMaxSequenceNumber;
Expand Down

0 comments on commit 20dea55

Please sign in to comment.