2017-10-06 17:26:38 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
|
|
|
|
#include "db/snapshot_checker.h"
|
|
|
|
|
|
|
|
|
2022-05-17 16:39:22 +00:00
|
|
|
#include "port/lang.h"
|
2017-11-02 18:05:55 +00:00
|
|
|
#include "utilities/transactions/write_prepared_txn_db.h"
|
2017-10-06 17:26:38 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2017-10-06 17:26:38 +00:00
|
|
|
|
|
|
|
|
2017-10-18 16:09:31 +00:00
|
|
|
WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
|
|
|
|
WritePreparedTxnDB* txn_db)
|
2017-10-06 17:26:38 +00:00
|
|
|
: txn_db_(txn_db){};
|
|
|
|
|
2019-01-16 17:48:10 +00:00
|
|
|
SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
|
2017-10-18 16:09:31 +00:00
|
|
|
SequenceNumber sequence, SequenceNumber snapshot_sequence) const {
|
2019-01-16 17:48:10 +00:00
|
|
|
bool snapshot_released = false;
|
|
|
|
// TODO(myabandeh): set min_uncommitted
|
|
|
|
bool in_snapshot = txn_db_->IsInSnapshot(
|
2019-04-02 21:43:03 +00:00
|
|
|
sequence, snapshot_sequence, kMinUnCommittedSeq, &snapshot_released);
|
2019-01-16 17:48:10 +00:00
|
|
|
if (snapshot_released) {
|
|
|
|
return SnapshotCheckerResult::kSnapshotReleased;
|
|
|
|
}
|
|
|
|
return in_snapshot ? SnapshotCheckerResult::kInSnapshot
|
|
|
|
: SnapshotCheckerResult::kNotInSnapshot;
|
2017-10-06 17:26:38 +00:00
|
|
|
}
|
2017-10-18 16:09:31 +00:00
|
|
|
|
2017-10-06 17:26:38 +00:00
|
|
|
|
2022-05-17 16:39:22 +00:00
|
|
|
DisableGCSnapshotChecker* DisableGCSnapshotChecker::Instance() {
|
|
|
|
STATIC_AVOID_DESTRUCTION(DisableGCSnapshotChecker, instance);
|
|
|
|
return &instance;
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|