summaryrefslogtreecommitdiff
path: root/src/mongo/db/vector_clock.h
diff options
context:
space:
mode:
authorPierlauro Sciarelli <pierlauro.sciarelli@mongodb.com>2020-07-15 19:46:11 +0200
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-07-16 21:34:39 +0000
commit97fd38d397f586d2d296714cfe3a27dafb37b26a (patch)
tree4d93577501dadbd70ef885631362de58e0b6d17d /src/mongo/db/vector_clock.h
parentdb63f4a342f836eb7c9e39a5a05e33af4b19dd4f (diff)
downloadmongo-97fd38d397f586d2d296714cfe3a27dafb37b26a.tar.gz
SERVER-48717 Implement the persist/recover functionalities of the VectorClock
Diffstat (limited to 'src/mongo/db/vector_clock.h')
-rw-r--r--src/mongo/db/vector_clock.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/mongo/db/vector_clock.h b/src/mongo/db/vector_clock.h
index 6434cd3aa6b..750f3a9133c 100644
--- a/src/mongo/db/vector_clock.h
+++ b/src/mongo/db/vector_clock.h
@@ -31,11 +31,14 @@
#include <array>
+#include "mongo/client/query.h"
#include "mongo/db/logical_time.h"
#include "mongo/db/operation_context.h"
#include "mongo/db/service_context.h"
+#include "mongo/db/vector_clock_document_gen.h"
#include "mongo/platform/mutex.h"
#include "mongo/transport/session.h"
+#include "mongo/util/static_immortal.h"
namespace mongo {
@@ -132,9 +135,32 @@ public:
*/
bool isEnabled() const;
+ /*
+ * Methods to save/recover the the vector clock to/from persistent storage. Subclasses are
+ * eventually expected to override those method to provide persistence mechanisms. Default
+ * implementations result in a NOP.
+ */
+ virtual SharedSemiFuture<void> persist(OperationContext* opCtx) {
+ return SharedSemiFuture<void>();
+ }
+ virtual SharedSemiFuture<void> recover(OperationContext* opCtx) {
+ return SharedSemiFuture<void>();
+ }
+ virtual void waitForInMemoryVectorClockToBePersisted(OperationContext* opCtx) {}
+ virtual void waitForVectorClockToBeRecovered(OperationContext* opCtx){};
+
void resetVectorClock_forTest();
void advanceTime_forTest(Component component, LogicalTime newTime);
+ // Query to use when reading/writing the vector clock state document.
+ static const Query& kStateQuery() {
+ static StaticImmortal<Query> q{QUERY(VectorClockDocument::k_idFieldName << kDocIdKey)};
+ return *q;
+ }
+
+ // The _id value of the vector clock singleton document.
+ static constexpr StringData kDocIdKey = "vectorClockState"_sd;
+
protected:
class ComponentFormat {