diff options
author | Randolph Tan <randolph@10gen.com> | 2017-11-21 13:00:05 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2017-11-30 14:04:49 -0500 |
commit | 00e4df53051c768ead5fbb69c43f169dee57bcde (patch) | |
tree | de1ed999b4de7a821f5955770e2d7690ca427524 | |
parent | aa196ccd7598335cd75344f46ff98d47b78c70d7 (diff) | |
download | mongo-00e4df53051c768ead5fbb69c43f169dee57bcde.tar.gz |
SERVER-32043 Disallow users from creating new indexes in config.transactions
(cherry picked from commit a9d80bdbe5fa83ab72509958aa4788e20a6b07ef)
-rw-r--r-- | jstests/core/create_indexes.js | 6 | ||||
-rw-r--r-- | src/mongo/db/commands/create_indexes.cpp | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/jstests/core/create_indexes.js b/jstests/core/create_indexes.js index 53a8b6e68f3..e10b86a4e64 100644 --- a/jstests/core/create_indexes.js +++ b/jstests/core/create_indexes.js @@ -156,4 +156,10 @@ res = t.runCommand('createIndexes', {indexes: [{key: {star: 1}, name: '*'}]}); assert.commandFailedWithCode(res, ErrorCodes.BadValue); + // Test that user is not allowed to create indexes in config.transactions. + var configDB = db.getSiblingDB('config'); + res = configDB.runCommand( + {createIndexes: 'transactions', indexes: [{key: {star: 1}, name: 'star'}]}); + assert.commandFailedWithCode(res, ErrorCodes.IllegalOperation); + }()); diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp index 01f37ae4ac6..52c3d08fc1e 100644 --- a/src/mongo/db/commands/create_indexes.cpp +++ b/src/mongo/db/commands/create_indexes.cpp @@ -242,6 +242,12 @@ public: if (!status.isOK()) return appendCommandStatus(result, status); + // Disallow users from creating new indexes on config.transactions since the sessions + // code was optimized to not update indexes. + uassert(ErrorCodes::IllegalOperation, + str::stream() << "not allowed to create index on " << ns.ns(), + ns != NamespaceString::kSessionTransactionsTableNamespace); + auto specsWithStatus = parseAndValidateIndexSpecs(opCtx, ns, cmdObj, serverGlobalParams.featureCompatibility); if (!specsWithStatus.isOK()) { |