]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/utilities/transactions/snapshot_checker.cc
import 14.2.4 nautilus point release
[ceph.git] / ceph / src / rocksdb / utilities / transactions / snapshot_checker.cc
CommitLineData
11fdf7f2
TL
1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
5
6#include "db/snapshot_checker.h"
7
8#ifdef ROCKSDB_LITE
9#include <assert.h>
10#endif // ROCKSDB_LITE
11
12#include "utilities/transactions/write_prepared_txn_db.h"
13
14namespace rocksdb {
15
16#ifdef ROCKSDB_LITE
17WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
18 WritePreparedTxnDB* /*txn_db*/) {}
19
494da23a 20SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
11fdf7f2
TL
21 SequenceNumber /*sequence*/, SequenceNumber /*snapshot_sequence*/) const {
22 // Should never be called in LITE mode.
23 assert(false);
494da23a 24 return SnapshotCheckerResult::kInSnapshot;
11fdf7f2
TL
25}
26
27#else
28
29WritePreparedSnapshotChecker::WritePreparedSnapshotChecker(
30 WritePreparedTxnDB* txn_db)
31 : txn_db_(txn_db){};
32
494da23a 33SnapshotCheckerResult WritePreparedSnapshotChecker::CheckInSnapshot(
11fdf7f2 34 SequenceNumber sequence, SequenceNumber snapshot_sequence) const {
494da23a
TL
35 bool snapshot_released = false;
36 // TODO(myabandeh): set min_uncommitted
37 bool in_snapshot = txn_db_->IsInSnapshot(
38 sequence, snapshot_sequence, kMinUnCommittedSeq, &snapshot_released);
39 if (snapshot_released) {
40 return SnapshotCheckerResult::kSnapshotReleased;
41 }
42 return in_snapshot ? SnapshotCheckerResult::kInSnapshot
43 : SnapshotCheckerResult::kNotInSnapshot;
11fdf7f2
TL
44}
45
46#endif // ROCKSDB_LITE
47DisableGCSnapshotChecker DisableGCSnapshotChecker::instance_;
48
49} // namespace rocksdb