2017-10-06 19:26:38 +02: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"
|
|
|
|
|
|
|
|
#ifdef ROCKSDB_LITE
|
|
|
|
#include <assert.h>
|
|
|
|
#endif // ROCKSDB_LITE
|
|
|
|
|
2017-11-02 19:05:55 +01:00
|
|
|
#include "utilities/transactions/write_prepared_txn_db.h"
|
2017-10-06 19:26:38 +02:00
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
#ifdef ROCKSDB_LITE
|
2017-10-18 18:09:31 +02:00
|
|
|
WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
|
2018-04-13 02:55:14 +02:00
|
|
|
WritePreparedTxnDB* /*txn_db*/) {}
|
2017-10-06 19:26:38 +02:00
|
|
|
|
2019-01-16 18:48:10 +01:00
|
|
|
SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
|
2018-04-13 02:55:14 +02:00
|
|
|
SequenceNumber /*sequence*/, SequenceNumber /*snapshot_sequence*/) const {
|
2017-10-06 19:26:38 +02:00
|
|
|
// Should never be called in LITE mode.
|
|
|
|
assert(false);
|
2019-01-16 18:48:10 +01:00
|
|
|
return SnapshotCheckerResult::kInSnapshot;
|
2017-10-06 19:26:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2017-10-18 18:09:31 +02:00
|
|
|
WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
|
|
|
|
WritePreparedTxnDB* txn_db)
|
2017-10-06 19:26:38 +02:00
|
|
|
: txn_db_(txn_db){};
|
|
|
|
|
2019-01-16 18:48:10 +01:00
|
|
|
SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
|
2017-10-18 18:09:31 +02:00
|
|
|
SequenceNumber sequence, SequenceNumber snapshot_sequence) const {
|
2019-01-16 18:48:10 +01:00
|
|
|
bool snapshot_released = false;
|
|
|
|
// TODO(myabandeh): set min_uncommitted
|
|
|
|
bool in_snapshot = txn_db_->IsInSnapshot(
|
2019-04-02 23:43:03 +02:00
|
|
|
sequence, snapshot_sequence, kMinUnCommittedSeq, &snapshot_released);
|
2019-01-16 18:48:10 +01:00
|
|
|
if (snapshot_released) {
|
|
|
|
return SnapshotCheckerResult::kSnapshotReleased;
|
|
|
|
}
|
|
|
|
return in_snapshot ? SnapshotCheckerResult::kInSnapshot
|
|
|
|
: SnapshotCheckerResult::kNotInSnapshot;
|
2017-10-06 19:26:38 +02:00
|
|
|
}
|
2017-10-18 18:09:31 +02:00
|
|
|
|
2017-10-06 19:26:38 +02:00
|
|
|
#endif // ROCKSDB_LITE
|
2017-10-18 18:09:31 +02:00
|
|
|
DisableGCSnapshotChecker DisableGCSnapshotChecker::instance_;
|
2017-10-06 19:26:38 +02:00
|
|
|
|
|
|
|
} // namespace rocksdb
|