0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-22360 disallow external sort in readOnly mode

This commit is contained in:
Adam Midvidy 2016-02-24 14:19:19 -05:00
parent 3a5c0f9bcb
commit c29b47c092
5 changed files with 20 additions and 0 deletions

View File

@ -93,6 +93,16 @@ runReadOnlyTest(function() {
{_id: "The Revenant", count: 3},
{_id: "Spotlight", count: 3}
]);
// Check that pipelines fail with allowDiskUse true. We use runCommand manually because
// the helper has conflicting error handling logic.
var allowDiskUseCmd = {aggregate: readableCollection.getName(),
pipeline: [],
allowDiskUse: true};
assert.commandFailedWithCode(readableCollection.runCommand(allowDiskUseCmd),
ErrorCodes.IllegalOperation,
"'allowDiskUse' is not allowed in read-only mode");
}
};
}());

View File

@ -123,6 +123,7 @@ docSourceEnv.Library(
'$BUILD_DIR/mongo/client/clientdriver',
'$BUILD_DIR/mongo/db/matcher/expressions',
'$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/storage/storage_options',
'$BUILD_DIR/mongo/db/storage/wiredtiger/storage_wiredtiger_customization_hooks',
'$BUILD_DIR/third_party/shim_snappy',
],
@ -146,6 +147,7 @@ env.Library(
'$BUILD_DIR/mongo/db/auth/authorization_manager_global',
'$BUILD_DIR/mongo/db/auth/authcore',
'$BUILD_DIR/mongo/db/repl/read_concern_args',
'$BUILD_DIR/mongo/db/storage/storage_options',
]
)

View File

@ -120,6 +120,10 @@ intrusive_ptr<Pipeline> Pipeline::parseCommand(string& errmsg,
}
if (str::equals(pFieldName, "allowDiskUse")) {
uassert(ErrorCodes::IllegalOperation,
"The 'allowDiskUse' option is not permitted in read-only mode.",
!storageGlobalParams.readOnly);
uassert(16949,
str::stream() << "allowDiskUse must be a bool, not a "
<< typeName(cmdElement.type()),

View File

@ -6,4 +6,5 @@ sorterEnv.CppUnitTest('sorter_test',
'sorter_test.cpp',
LIBDEPS=['$BUILD_DIR/mongo/db/service_context',
'$BUILD_DIR/mongo/db/storage/wiredtiger/storage_wiredtiger_customization_hooks',
'$BUILD_DIR/mongo/db/storage/storage_options',
'$BUILD_DIR/third_party/shim_snappy'])

View File

@ -770,6 +770,9 @@ private:
<< " Pass allowDiskUse:true to opt in.");
}
// We should check readOnly before getting here.
invariant(!storageGlobalParams.readOnly);
sort();
updateCutoff();