Storage Engine API
wiredtiger_snapshot_manager.h
Go to the documentation of this file.
1 
30 #pragma once
31 
32 #include <boost/optional.hpp>
33 #include <wiredtiger.h>
34 
35 #include "mongo/base/disallow_copying.h"
36 #include "mongo/bson/timestamp.h"
39 #include "mongo/stdx/mutex.h"
40 
41 namespace mongo {
42 
43 class WiredTigerOplogManager;
44 
47 
48 public:
49  WiredTigerSnapshotManager() = default;
50 
51  void setCommittedSnapshot(const Timestamp& timestamp) final;
52  void setLocalSnapshot(const Timestamp& timestamp) final;
53  boost::optional<Timestamp> getLocalSnapshot() final;
54  void dropAllSnapshots() final;
55 
56  //
57  // WT-specific methods
58  //
59 
65  Timestamp beginTransactionOnCommittedSnapshot(WT_SESSION* session) const;
66 
73  WT_SESSION* session, WiredTigerBeginTxnBlock::IgnorePrepared ignorePrepared) const;
74 
83  boost::optional<Timestamp> getMinSnapshotForNextCommittedRead() const;
84 
85 private:
86  // Snapshot to use for reads at a commit timestamp.
87  mutable stdx::mutex _committedSnapshotMutex; // Guards _committedSnapshot.
88  boost::optional<Timestamp> _committedSnapshot;
89 
90  // Snapshot to use for reads at a local stable timestamp.
91  mutable stdx::mutex _localSnapshotMutex; // Guards _localSnapshot.
92  boost::optional<Timestamp> _localSnapshot;
93 };
94 }
void setCommittedSnapshot(const Timestamp &timestamp) final
Sets the snapshot to be used for committed reads.
Definition: wiredtiger_snapshot_manager.cpp:43
stdx::mutex _localSnapshotMutex
Definition: wiredtiger_snapshot_manager.h:91
boost::optional< Timestamp > getMinSnapshotForNextCommittedRead() const
Returns lowest SnapshotName that could possibly be used by a future call to beginTransactionOnCommitt...
Definition: wiredtiger_snapshot_manager.cpp:65
boost::optional< Timestamp > _localSnapshot
Definition: wiredtiger_snapshot_manager.h:92
IgnorePrepared
Definition: wiredtiger_begin_transaction_block.h:48
void dropAllSnapshots() final
Drops all snapshots and clears the "committed" snapshot.
Definition: wiredtiger_snapshot_manager.cpp:60
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
stdx::mutex _committedSnapshotMutex
Definition: wiredtiger_snapshot_manager.h:87
void setLocalSnapshot(const Timestamp &timestamp) final
Sets the snapshot for the last stable timestamp for reading on secondaries.
Definition: wiredtiger_snapshot_manager.cpp:50
MONGO_DISALLOW_COPYING(WiredTigerSnapshotManager)
Timestamp beginTransactionOnCommittedSnapshot(WT_SESSION *session) const
Starts a transaction and returns the SnapshotName used.
Definition: wiredtiger_snapshot_manager.cpp:70
boost::optional< Timestamp > getLocalSnapshot() final
Returns the local snapshot timestamp.
Definition: wiredtiger_snapshot_manager.cpp:55
Manages snapshots that can be read from at a later time.
Definition: snapshot_manager.h:47
boost::optional< Timestamp > _committedSnapshot
Definition: wiredtiger_snapshot_manager.h:88
Definition: wiredtiger_snapshot_manager.h:45
Timestamp beginTransactionOnLocalSnapshot(WT_SESSION *session, WiredTigerBeginTxnBlock::IgnorePrepared ignorePrepared) const
Starts a transaction on the last stable local timestamp, set by setLocalSnapshot. ...
Definition: wiredtiger_snapshot_manager.cpp:86