summaryrefslogtreecommitdiff
path: root/src/mongo/db/db_raii.h
diff options
context:
space:
mode:
authorCharlie Swanson <charlie.swanson@mongodb.com>2019-02-05 11:43:52 -0500
committerCharlie Swanson <charlie.swanson@mongodb.com>2019-02-11 12:13:38 -0500
commitd568e329a67eee8ba241d52067750a3d8c42dc0f (patch)
treee8180ccc44f243f603cb91eaed431afeeabe8676 /src/mongo/db/db_raii.h
parentb54d9905a167867a2655910799573378aff2ce89 (diff)
downloadmongo-d568e329a67eee8ba241d52067750a3d8c42dc0f.tar.gz
SERVER-37283 Use stronger locks for system.views
Readers of the view catalog depend on a MODE_IS DB lock preventing concurrent writes to the view catalog. This is true for regular view maintenance commands like collMod, create, and drop. However, on secondaries these commands are replicated as direct writes to system.views and do not hold as strong of a lock. Further, a user is permitted to write directly to system.views and so could hit a similar issue on the primary.
Diffstat (limited to 'src/mongo/db/db_raii.h')
-rw-r--r--src/mongo/db/db_raii.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mongo/db/db_raii.h b/src/mongo/db/db_raii.h
index 39a30282630..40ede468e0d 100644
--- a/src/mongo/db/db_raii.h
+++ b/src/mongo/db/db_raii.h
@@ -215,7 +215,8 @@ private:
/**
* Returns a MODE_IX LockMode if a read is performed under readConcern level snapshot, or a MODE_IS
* lock otherwise. MODE_IX acquisition will allow a read to participate in two-phase locking.
+ * Throws an exception if 'system.views' is being queried within a transaction.
*/
-LockMode getLockModeForQuery(OperationContext* opCtx);
+LockMode getLockModeForQuery(OperationContext* opCtx, const boost::optional<NamespaceString>& nss);
} // namespace mongo