summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-10-02 15:30:16 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-10-03 08:34:22 -0400
commit2217ee242cf401e3820bc3a046c6341c5537669f (patch)
treee182dfe8bffc527caf726c2cff0754b5b66779c1
parentf50acb128dc0485b48d8045587579ba48ae888b4 (diff)
downloadmongo-2217ee242cf401e3820bc3a046c6341c5537669f.tar.gz
SERVER-31349 Rename 'disallowCollectionCreation' generic argument to 'allowImplicitCollectionCreation'
-rw-r--r--src/mongo/db/catalog/database_impl.cpp30
-rw-r--r--src/mongo/db/commands.h34
-rw-r--r--src/mongo/db/s/operation_sharding_state.cpp14
-rw-r--r--src/mongo/db/s/operation_sharding_state.h10
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp8
-rw-r--r--src/mongo/s/commands/cluster_commands_helpers.cpp2
6 files changed, 51 insertions, 47 deletions
diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp
index f5b036a3a56..89b50ee1c35 100644
--- a/src/mongo/db/catalog/database_impl.cpp
+++ b/src/mongo/db/catalog/database_impl.cpp
@@ -409,7 +409,7 @@ void DatabaseImpl::getStats(OperationContext* opCtx, BSONObjBuilder* output, dou
_dbEntry->appendExtraStats(opCtx, output, scale);
- if (!getGlobalServiceContext()->getGlobalStorageEngine()->isEphemeral()) {
+ if (!opCtx->getServiceContext()->getGlobalStorageEngine()->isEphemeral()) {
boost::filesystem::path dbpath(storageGlobalParams.dbpath);
if (storageGlobalParams.directoryperdb) {
dbpath /= _name;
@@ -431,7 +431,7 @@ void DatabaseImpl::getStats(OperationContext* opCtx, BSONObjBuilder* output, dou
Status DatabaseImpl::dropView(OperationContext* opCtx, StringData fullns) {
Status status = _views.dropView(opCtx, NamespaceString(fullns));
- Top::get(opCtx->getClient()->getServiceContext()).collectionDropped(fullns);
+ Top::get(opCtx->getServiceContext()).collectionDropped(fullns);
return status;
}
@@ -497,7 +497,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx,
audit::logDropCollection(&cc(), fullns.toString());
- Top::get(opCtx->getClient()->getServiceContext()).collectionDropped(fullns.toString());
+ Top::get(opCtx->getServiceContext()).collectionDropped(fullns.toString());
auto uuid = collection->uuid();
@@ -506,7 +506,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx,
// Under master/slave, collections are always dropped immediately. This is because drop-pending
// collections support the rollback process which is not applicable to master/slave.
auto replCoord = repl::ReplicationCoordinator::get(opCtx);
- auto opObserver = getGlobalServiceContext()->getOpObserver();
+ auto opObserver = opCtx->getServiceContext()->getOpObserver();
auto isOplogDisabledForNamespace = replCoord->isOplogDisabledFor(opCtx, fullns);
auto isMasterSlave =
repl::ReplicationCoordinator::modeMasterSlave == replCoord->getReplicationMode();
@@ -682,7 +682,7 @@ Status DatabaseImpl::renameCollection(OperationContext* opCtx,
_clearCollectionCache(opCtx, fromNS, clearCacheReason, /*collectionGoingAway*/ true);
_clearCollectionCache(opCtx, toNS, clearCacheReason, /*collectionGoingAway*/ false);
- Top::get(opCtx->getClient()->getServiceContext()).collectionDropped(fromNS.toString());
+ Top::get(opCtx->getServiceContext()).collectionDropped(fromNS.toString());
}
opCtx->recoveryUnit()->registerChange(new AddCollectionChange(opCtx, this, toNS));
@@ -759,8 +759,8 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx,
NamespaceString nss(ns);
uassert(ErrorCodes::CannotImplicitlyCreateCollection,
- "request was sent with 'disallowCollectionCreation' field",
- OperationShardingState::get(opCtx).allowCollectionCreation());
+ "request doesn't allow collection to be created implicitly",
+ OperationShardingState::get(opCtx).allowImplicitCollectionCreation());
CollectionOptions optionsWithUUID = options;
if (enableCollectionUUIDs && !optionsWithUUID.uuid &&
@@ -807,7 +807,7 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx,
}
}
- getGlobalServiceContext()->getOpObserver()->onCreateCollection(
+ opCtx->getServiceContext()->getOpObserver()->onCreateCollection(
opCtx, collection, nss, optionsWithUUID, fullIdIndexSpec);
return collection;
@@ -830,17 +830,17 @@ void DatabaseImpl::dropDatabase(OperationContext* opCtx, Database* db) {
audit::logDropDatabase(opCtx->getClient(), name);
+ auto const serviceContext = opCtx->getServiceContext();
+
for (auto&& coll : *db) {
- Top::get(opCtx->getClient()->getServiceContext()).collectionDropped(coll->ns().ns(), true);
+ Top::get(serviceContext).collectionDropped(coll->ns().ns(), true);
}
dbHolder().close(opCtx, name, "database dropped");
+ auto const storageEngine = serviceContext->getGlobalStorageEngine();
writeConflictRetry(opCtx, "dropDatabase", name, [&] {
- getGlobalServiceContext()
- ->getGlobalStorageEngine()
- ->dropDatabase(opCtx, name)
- .transitional_ignore();
+ storageEngine->dropDatabase(opCtx, name).transitional_ignore();
});
}
@@ -928,14 +928,14 @@ void mongo::dropAllDatabasesExceptLocalImpl(OperationContext* opCtx) {
Lock::GlobalWrite lk(opCtx);
vector<string> n;
- StorageEngine* storageEngine = getGlobalServiceContext()->getGlobalStorageEngine();
+ StorageEngine* storageEngine = opCtx->getServiceContext()->getGlobalStorageEngine();
storageEngine->listDatabases(&n);
if (n.size() == 0)
return;
log() << "dropAllDatabasesExceptLocal " << n.size();
- repl::getGlobalReplicationCoordinator()->dropAllSnapshots();
+ repl::ReplicationCoordinator::get(opCtx)->dropAllSnapshots();
for (const auto& dbName : n) {
if (dbName != "local") {
diff --git a/src/mongo/db/commands.h b/src/mongo/db/commands.h
index c2b91aa9b7a..463ce9a7f42 100644
--- a/src/mongo/db/commands.h
+++ b/src/mongo/db/commands.h
@@ -459,23 +459,23 @@ public:
// Not including "help" since we don't pass help requests through to the command parser.
// If that changes, it should be added. When you add to this list, consider whether you
// should also change the filterCommandRequestForPassthrough() function.
- return arg == "$audit" || //
- arg == "$client" || //
- arg == "$configServerState" || //
- arg == "$db" || //
- arg == "disallowCollectionCreation" || //
- arg == "$oplogQueryData" || //
- arg == "$queryOptions" || //
- arg == "$readPreference" || //
- arg == "$replData" || //
- arg == "$clusterTime" || //
- arg == "maxTimeMS" || //
- arg == "readConcern" || //
- arg == "shardVersion" || //
- arg == "tracking_info" || //
- arg == "writeConcern" || //
- arg == "lsid" || //
- arg == "txnNumber" || //
+ return arg == "$audit" || //
+ arg == "$client" || //
+ arg == "$configServerState" || //
+ arg == "$db" || //
+ arg == "allowImplicitCollectionCreation" || //
+ arg == "$oplogQueryData" || //
+ arg == "$queryOptions" || //
+ arg == "$readPreference" || //
+ arg == "$replData" || //
+ arg == "$clusterTime" || //
+ arg == "maxTimeMS" || //
+ arg == "readConcern" || //
+ arg == "shardVersion" || //
+ arg == "tracking_info" || //
+ arg == "writeConcern" || //
+ arg == "lsid" || //
+ arg == "txnNumber" || //
false; // These comments tell clang-format to keep this line-oriented.
}
diff --git a/src/mongo/db/s/operation_sharding_state.cpp b/src/mongo/db/s/operation_sharding_state.cpp
index 88d18bae218..dead0bd7dd0 100644
--- a/src/mongo/db/s/operation_sharding_state.cpp
+++ b/src/mongo/db/s/operation_sharding_state.cpp
@@ -50,13 +50,17 @@ OperationShardingState& OperationShardingState::get(OperationContext* opCtx) {
return shardingMetadataDecoration(opCtx);
}
-void OperationShardingState::setDisallowCollectionCreationIfNeeded(
- const BSONElement& disallowCollectionCreationElt) {
- _disallowCollectionCreation = disallowCollectionCreationElt.trueValue();
+void OperationShardingState::setAllowImplicitCollectionCreation(
+ const BSONElement& allowImplicitCollectionCreationElem) {
+ if (!allowImplicitCollectionCreationElem.eoo()) {
+ _allowImplicitCollectionCreation = allowImplicitCollectionCreationElem.Bool();
+ } else {
+ _allowImplicitCollectionCreation = true;
+ }
}
-bool OperationShardingState::allowCollectionCreation() {
- return !_disallowCollectionCreation;
+bool OperationShardingState::allowImplicitCollectionCreation() const {
+ return _allowImplicitCollectionCreation;
}
void OperationShardingState::initializeShardVersion(NamespaceString nss,
diff --git a/src/mongo/db/s/operation_sharding_state.h b/src/mongo/db/s/operation_sharding_state.h
index 7c42e8840f3..4a55173c09c 100644
--- a/src/mongo/db/s/operation_sharding_state.h
+++ b/src/mongo/db/s/operation_sharding_state.h
@@ -64,12 +64,12 @@ public:
* since the collection options will not be propagated. Such requests specify to disallow
* collection creation, which is saved here.
*/
- void setDisallowCollectionCreationIfNeeded(const BSONElement& disallowCollectionCreationElt);
+ void setAllowImplicitCollectionCreation(const BSONElement& allowImplicitCollectionCreationElem);
/**
- * Returns false if the request specified not to allow collection creation.
+ * Specifies whether the request is allowed to create database/collection implicitly.
*/
- bool allowCollectionCreation();
+ bool allowImplicitCollectionCreation() const;
/**
* Parses shard version from the command parameters 'cmdObj' and stores the results in this
@@ -131,8 +131,8 @@ private:
*/
void _clear();
- // This value is set if a request specifies not to allow collection creation.
- bool _disallowCollectionCreation = false;
+ // Specifies whether the request is allowed to create database/collection implicitly
+ bool _allowImplicitCollectionCreation{true};
bool _hasVersion = false;
ChunkVersion _shardVersion{ChunkVersion::UNSHARDED()};
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index 5cc7dd8eafb..8f9ea2f2a0f 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -555,7 +555,7 @@ void execCommandDatabase(OperationContext* opCtx,
std::unique_ptr<MaintenanceModeSetter> mmSetter;
BSONElement cmdOptionMaxTimeMSField;
- BSONElement disallowCollectionCreationField;
+ BSONElement allowImplicitCollectionCreationField;
BSONElement helpField;
BSONElement shardVersionFieldIdx;
BSONElement queryOptionMaxTimeMSField;
@@ -565,8 +565,8 @@ void execCommandDatabase(OperationContext* opCtx,
StringData fieldName = element.fieldNameStringData();
if (fieldName == QueryRequest::cmdOptionMaxTimeMS) {
cmdOptionMaxTimeMSField = element;
- } else if (fieldName == "disallowCollectionCreation") {
- disallowCollectionCreationField = element;
+ } else if (fieldName == "allowImplicitCollectionCreation") {
+ allowImplicitCollectionCreationField = element;
} else if (fieldName == Command::kHelpFieldName) {
helpField = element;
} else if (fieldName == ChunkVersion::kShardVersionField) {
@@ -698,7 +698,7 @@ void execCommandDatabase(OperationContext* opCtx,
uassertStatusOK(shardingState->updateConfigServerOpTimeFromMetadata(opCtx));
}
- oss.setDisallowCollectionCreationIfNeeded(disallowCollectionCreationField);
+ oss.setAllowImplicitCollectionCreation(allowImplicitCollectionCreationField);
// Can throw
opCtx->checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point.
diff --git a/src/mongo/s/commands/cluster_commands_helpers.cpp b/src/mongo/s/commands/cluster_commands_helpers.cpp
index e6f4e1a02fa..d60136864b4 100644
--- a/src/mongo/s/commands/cluster_commands_helpers.cpp
+++ b/src/mongo/s/commands/cluster_commands_helpers.cpp
@@ -254,7 +254,7 @@ StatusWith<std::vector<AsyncRequestsSender::Response>> scatterGatherOnlyVersionI
// options. So, we signal to shards that they should not implicitly create the collection.
BSONObjBuilder augmentedCmdBob;
augmentedCmdBob.appendElementsUnique(cmdObj);
- augmentedCmdBob.append("disallowCollectionCreation", true);
+ augmentedCmdBob.append("allowImplicitCollectionCreation", false);
requests = buildUnversionedRequestsForAllShards(opCtx, augmentedCmdBob.obj());
} else {
requests = buildVersionedRequestsForTargetedShards(