summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/minvalid.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/minvalid.cpp')
-rw-r--r--src/mongo/db/repl/minvalid.cpp122
1 files changed, 62 insertions, 60 deletions
diff --git a/src/mongo/db/repl/minvalid.cpp b/src/mongo/db/repl/minvalid.cpp
index 5cd3acd64e7..b14966486fe 100644
--- a/src/mongo/db/repl/minvalid.cpp
+++ b/src/mongo/db/repl/minvalid.cpp
@@ -46,74 +46,76 @@ namespace mongo {
namespace repl {
namespace {
- const char* initialSyncFlagString = "doingInitialSync";
- const BSONObj initialSyncFlag(BSON(initialSyncFlagString << true));
- const char* minvalidNS = "local.replset.minvalid";
-} // namespace
-
- // Writes
- void clearInitialSyncFlag(OperationContext* txn) {
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(txn, MODE_IX);
- // TODO: Investigate correctness of taking MODE_IX for DB/Collection locks
- Lock::DBLock dblk(txn->lockState(), "local", MODE_X);
- Helpers::putSingleton(txn, minvalidNS, BSON("$unset" << initialSyncFlag));
- } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "clearInitialSyncFlags", minvalidNS);
-
+const char* initialSyncFlagString = "doingInitialSync";
+const BSONObj initialSyncFlag(BSON(initialSyncFlagString << true));
+const char* minvalidNS = "local.replset.minvalid";
+} // namespace
+
+// Writes
+void clearInitialSyncFlag(OperationContext* txn) {
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ ScopedTransaction transaction(txn, MODE_IX);
+ // TODO: Investigate correctness of taking MODE_IX for DB/Collection locks
+ Lock::DBLock dblk(txn->lockState(), "local", MODE_X);
+ Helpers::putSingleton(txn, minvalidNS, BSON("$unset" << initialSyncFlag));
}
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "clearInitialSyncFlags", minvalidNS);
+}
- void setInitialSyncFlag(OperationContext* txn) {
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(txn, MODE_IX);
- Lock::DBLock dblk(txn->lockState(), "local", MODE_X);
- Helpers::putSingleton(txn, minvalidNS, BSON("$set" << initialSyncFlag));
- } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "setInitialSyncFlags", minvalidNS);
+void setInitialSyncFlag(OperationContext* txn) {
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ ScopedTransaction transaction(txn, MODE_IX);
+ Lock::DBLock dblk(txn->lockState(), "local", MODE_X);
+ Helpers::putSingleton(txn, minvalidNS, BSON("$set" << initialSyncFlag));
}
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "setInitialSyncFlags", minvalidNS);
+}
- void setMinValid(OperationContext* ctx, const OpTime& opTime) {
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(ctx, MODE_IX);
- Lock::DBLock dblk(ctx->lockState(), "local", MODE_X);
- Helpers::putSingleton(ctx,
- minvalidNS,
- BSON("$set" << BSON("ts" << opTime.getTimestamp() <<
- "t" << opTime.getTerm())));
-
- } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(ctx, "setMinValid", minvalidNS);
+void setMinValid(OperationContext* ctx, const OpTime& opTime) {
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ ScopedTransaction transaction(ctx, MODE_IX);
+ Lock::DBLock dblk(ctx->lockState(), "local", MODE_X);
+ Helpers::putSingleton(
+ ctx,
+ minvalidNS,
+ BSON("$set" << BSON("ts" << opTime.getTimestamp() << "t" << opTime.getTerm())));
}
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(ctx, "setMinValid", minvalidNS);
+}
- // Reads
- bool getInitialSyncFlag() {
- OperationContextImpl txn;
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(&txn, MODE_IS);
- Lock::DBLock dblk(txn.lockState(), "local", MODE_IS);
- Lock::CollectionLock lk(txn.lockState(), minvalidNS, MODE_IS);
- BSONObj mv;
- bool found = Helpers::getSingleton( &txn, minvalidNS, mv);
-
- if (found) {
- return mv[initialSyncFlagString].trueValue();
- }
- return false;
- } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(&txn, "getInitialSyncFlags", minvalidNS);
-
- MONGO_UNREACHABLE;
+// Reads
+bool getInitialSyncFlag() {
+ OperationContextImpl txn;
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ ScopedTransaction transaction(&txn, MODE_IS);
+ Lock::DBLock dblk(txn.lockState(), "local", MODE_IS);
+ Lock::CollectionLock lk(txn.lockState(), minvalidNS, MODE_IS);
+ BSONObj mv;
+ bool found = Helpers::getSingleton(&txn, minvalidNS, mv);
+
+ if (found) {
+ return mv[initialSyncFlagString].trueValue();
+ }
+ return false;
}
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(&txn, "getInitialSyncFlags", minvalidNS);
- OpTime getMinValid(OperationContext* txn) {
- MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
- ScopedTransaction transaction(txn, MODE_IS);
- Lock::DBLock dblk(txn->lockState(), "local", MODE_IS);
- Lock::CollectionLock lk(txn->lockState(), minvalidNS, MODE_IS);
- BSONObj mv;
- bool found = Helpers::getSingleton(txn, minvalidNS, mv);
- if (found) {
- return extractOpTime(mv);
- }
- return OpTime();
- } MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "getMinValid", minvalidNS);
- }
+ MONGO_UNREACHABLE;
+}
+OpTime getMinValid(OperationContext* txn) {
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_BEGIN {
+ ScopedTransaction transaction(txn, MODE_IS);
+ Lock::DBLock dblk(txn->lockState(), "local", MODE_IS);
+ Lock::CollectionLock lk(txn->lockState(), minvalidNS, MODE_IS);
+ BSONObj mv;
+ bool found = Helpers::getSingleton(txn, minvalidNS, mv);
+ if (found) {
+ return extractOpTime(mv);
+ }
+ return OpTime();
+ }
+ MONGO_WRITE_CONFLICT_RETRY_LOOP_END(txn, "getMinValid", minvalidNS);
+}
}
}