summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.cpp
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-08-10 15:28:22 -0400
committerMathias Stearn <mathias@10gen.com>2015-08-12 17:00:59 -0400
commit7c7487b3e0c98739249de33e84dbc76f50bd5717 (patch)
treeaa47d4f5f4b9d15f6bcd60583e0d7d4c2cdf9368 /src/mongo/db/db_raii.cpp
parent7c05241d8001a30791732235cea2fff2e52f43e0 (diff)
downloadmongo-7c7487b3e0c98739249de33e84dbc76f50bd5717.tar.gz
SERVER-19212 Hide indexes and collections from stale majority concern reads
Reading from a collection will error out if the snapshot used by the query is older than the collection creation or the point when the last index was dropped from a collection. New indexes do not cause reads to fail, but reads cannot use the new indexes since they may be incomplete in the snapshot.
Diffstat (limited to 'src/mongo/db/db_raii.cpp')
-rw-r--r--src/mongo/db/db_raii.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/db/db_raii.cpp b/src/mongo/db/db_raii.cpp
index 9cf314c7b76..dabc86ad475 100644
--- a/src/mongo/db/db_raii.cpp
+++ b/src/mongo/db/db_raii.cpp
@@ -31,6 +31,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/catalog/database_holder.h"
+#include "mongo/db/catalog/collection.h"
#include "mongo/db/client.h"
#include "mongo/db/curop.h"
#include "mongo/db/stats/top.h"
@@ -97,6 +98,18 @@ void AutoGetCollectionForRead::_init(const std::string& ns, StringData coll) {
_coll = _db.getDb()->getCollection(ns);
}
+
+ if (_coll) {
+ if (auto minSnapshot = _coll->getMinimumVisibleSnapshot()) {
+ if (auto mySnapshot = _txn->recoveryUnit()->getMajorityCommittedSnapshot()) {
+ uassert(ErrorCodes::ReadConcernMajorityNotAvailableYet,
+ str::stream()
+ << "Majority read concern is not currently available for collection "
+ << ns,
+ mySnapshot >= minSnapshot);
+ }
+ }
+ }
}
AutoGetCollectionForRead::~AutoGetCollectionForRead() {