summaryrefslogtreecommitdiff
path: root/src/mongo/s/client/shard_local.h
diff options
context:
space:
mode:
authorSpencer T Brody <spencer@mongodb.com>2016-06-27 18:46:49 -0400
committerSpencer T Brody <spencer@mongodb.com>2016-07-06 11:59:53 -0400
commit88daeb804d093011144cb5e3a0295aa9eb89c42b (patch)
tree4b9b42f4172811dd9fd9374600c75c6128ba695f /src/mongo/s/client/shard_local.h
parentbf202053528309d2d2040d023fe332986f6457c2 (diff)
downloadmongo-88daeb804d093011144cb5e3a0295aa9eb89c42b.tar.gz
SERVER-24817 Make ShardLocal wait for writes it performed when doing majority reads
This gives config servers read-your-own-write semantics, even when the writes are performed as w:1 and the reads have readConcern:majority
Diffstat (limited to 'src/mongo/s/client/shard_local.h')
-rw-r--r--src/mongo/s/client/shard_local.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mongo/s/client/shard_local.h b/src/mongo/s/client/shard_local.h
index b39aba621d0..1c65015b78e 100644
--- a/src/mongo/s/client/shard_local.h
+++ b/src/mongo/s/client/shard_local.h
@@ -30,7 +30,9 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/client/dbclientinterface.h"
+#include "mongo/db/repl/optime.h"
#include "mongo/s/client/shard.h"
+#include "mongo/stdx/mutex.h"
namespace mongo {
@@ -75,6 +77,23 @@ private:
const BSONObj& query,
const BSONObj& sort,
boost::optional<long long> limit) final;
+
+ /**
+ * Checks if an OpTime was set on the current Client (ie if the current operation performed a
+ * write) and if so updates _lastOpTime to the OpTime from the write that was just performed.
+ */
+ void _updateLastOpTimeFromClient(OperationContext* txn);
+
+ repl::OpTime _getLastOpTime();
+
+ // Guards _lastOpTime below.
+ stdx::mutex _mutex;
+
+ // Stores the optime that was generated by the last operation to perform a write that was run
+ // through _runCommand. Used in _exhaustiveFindOnConfig for waiting for that optime to be
+ // committed so that readConcern majority reads will read the writes that were performed without
+ // a w:majority write concern.
+ repl::OpTime _lastOpTime{};
};
} // namespace mongo