diff options
author | Gabriel Russell <gabriel.russell@mongodb.com> | 2020-02-13 11:49:46 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-02-13 18:16:35 +0000 |
commit | a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761 (patch) | |
tree | 85ac46cd5f4ea6d5134560bf764fb9e6cf11fe4e /src/mongo/db/s/config | |
parent | 6df40e01f7b6899affc4536e7e73a35802cabf98 (diff) | |
download | mongo-a84c09a19720b73cedb2e8ef7c5cfeedfa1c9761.tar.gz |
SERVER-45869 automatically converted structured logging
Diffstat (limited to 'src/mongo/db/s/config')
7 files changed, 90 insertions, 43 deletions
diff --git a/src/mongo/db/s/config/configsvr_add_shard_command.cpp b/src/mongo/db/s/config/configsvr_add_shard_command.cpp index bf61721b30f..6f6b449b0cf 100644 --- a/src/mongo/db/s/config/configsvr_add_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_add_shard_command.cpp @@ -42,6 +42,7 @@ #include "mongo/db/repl/repl_set_config.h" #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/s/config/sharding_catalog_manager.h" +#include "mongo/logv2/log.h" #include "mongo/s/catalog/type_shard.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/add_shard_request_type.h" @@ -129,8 +130,10 @@ public: parsedRequest.hasMaxSize() ? parsedRequest.getMaxSize() : kMaxSizeMBDefault); if (!addShardResult.isOK()) { - log() << "addShard request '" << parsedRequest << "'" - << "failed" << causedBy(addShardResult.getStatus()); + LOGV2(21920, + "addShard request '{parsedRequest}'failed{causedBy_addShardResult_getStatus}", + "parsedRequest"_attr = parsedRequest, + "causedBy_addShardResult_getStatus"_attr = causedBy(addShardResult.getStatus())); uassertStatusOK(addShardResult.getStatus()); } diff --git a/src/mongo/db/s/config/configsvr_move_primary_command.cpp b/src/mongo/db/s/config/configsvr_move_primary_command.cpp index fe5c843303e..1595d7fdcdd 100644 --- a/src/mongo/db/s/config/configsvr_move_primary_command.cpp +++ b/src/mongo/db/s/config/configsvr_move_primary_command.cpp @@ -44,6 +44,7 @@ #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/s/config/sharding_catalog_manager.h" #include "mongo/db/server_options.h" +#include "mongo/logv2/log.h" #include "mongo/s/catalog/type_database.h" #include "mongo/s/catalog_cache.h" #include "mongo/s/client/shard_registry.h" @@ -158,8 +159,13 @@ public: const auto toShard = [&]() { auto toShardStatus = shardRegistry->getShard(opCtx, to); if (!toShardStatus.isOK()) { - log() << "Could not move database '" << dbname << "' to shard '" << to - << causedBy(toShardStatus.getStatus()); + LOGV2(21921, + "Could not move database '{dbname}' to shard " + "'{to}{causedBy_toShardStatus_getStatus}", + "dbname"_attr = dbname, + "to"_attr = to, + "causedBy_toShardStatus_getStatus"_attr = + causedBy(toShardStatus.getStatus())); uassertStatusOKWithContext(toShardStatus.getStatus(), str::stream() << "Could not move database '" << dbname << "' to shard '" << to << "'"); diff --git a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp index 3b6a9337014..3d862d632d1 100644 --- a/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp +++ b/src/mongo/db/s/config/configsvr_refine_collection_shard_key_command.cpp @@ -38,6 +38,7 @@ #include "mongo/db/s/config/sharding_catalog_manager.h" #include "mongo/db/s/shard_key_util.h" #include "mongo/db/server_options.h" +#include "mongo/logv2/log.h" #include "mongo/s/catalog/dist_lock_manager.h" #include "mongo/s/grid.h" #include "mongo/s/request_types/refine_collection_shard_key_gen.h" @@ -148,7 +149,9 @@ public: collType.getUnique(), false); // createIndexIfPossible - LOG(0) << "CMD: refineCollectionShardKey: " << request().toBSON({}); + LOGV2(21922, + "CMD: refineCollectionShardKey: {request}", + "request"_attr = request().toBSON({})); audit::logRefineCollectionShardKey(opCtx->getClient(), nss.ns(), proposedKey); diff --git a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp index 9fd9e7298b4..2b3cfc9a1ae 100644 --- a/src/mongo/db/s/config/configsvr_remove_shard_command.cpp +++ b/src/mongo/db/s/config/configsvr_remove_shard_command.cpp @@ -42,6 +42,7 @@ #include "mongo/db/operation_context.h" #include "mongo/db/repl/read_concern_args.h" #include "mongo/db/s/config/sharding_catalog_manager.h" +#include "mongo/logv2/log.h" #include "mongo/s/catalog/type_database.h" #include "mongo/s/catalog_cache.h" #include "mongo/s/client/shard_registry.h" @@ -116,7 +117,7 @@ public: try { return shardingCatalogManager->removeShard(opCtx, shardId); } catch (const DBException& ex) { - LOG(0) << "Failed to remove shard due to " << redact(ex); + LOGV2(21923, "Failed to remove shard due to {ex}", "ex"_attr = redact(ex)); throw; } }(); diff --git a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp index 38ef0df3f11..b1d23be5b0c 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_collection_operations.cpp @@ -56,6 +56,7 @@ #include "mongo/db/s/sharding_logging.h" #include "mongo/executor/network_interface.h" #include "mongo/executor/task_executor.h" +#include "mongo/logv2/log.h" #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/s/balancer_configuration.h" #include "mongo/s/catalog/sharding_catalog_client_impl.h" @@ -421,15 +422,16 @@ void ShardingCatalogManager::dropCollection(OperationContext* opCtx, const Names BSONObj(), ShardingCatalogClient::kMajorityWriteConcern)); - LOG(1) << "dropCollection " << nss.ns() << " started"; + LOGV2_DEBUG(21924, 1, "dropCollection {nss_ns} started", "nss_ns"_attr = nss.ns()); sendDropCollectionToAllShards(opCtx, nss); - LOG(1) << "dropCollection " << nss.ns() << " shard data deleted"; + LOGV2_DEBUG(21925, 1, "dropCollection {nss_ns} shard data deleted", "nss_ns"_attr = nss.ns()); removeChunksAndTagsForDroppedCollection(opCtx, nss); - LOG(1) << "dropCollection " << nss.ns() << " chunk and tag data deleted"; + LOGV2_DEBUG( + 21926, 1, "dropCollection {nss_ns} chunk and tag data deleted", "nss_ns"_attr = nss.ns()); // Mark the collection as dropped CollectionType coll; @@ -442,11 +444,12 @@ void ShardingCatalogManager::dropCollection(OperationContext* opCtx, const Names uassertStatusOK(ShardingCatalogClientImpl::updateShardingCatalogEntryForCollection( opCtx, nss, coll, upsert)); - LOG(1) << "dropCollection " << nss.ns() << " collection marked as dropped"; + LOGV2_DEBUG( + 21927, 1, "dropCollection {nss_ns} collection marked as dropped", "nss_ns"_attr = nss.ns()); sendSSVToAllShards(opCtx, nss); - LOG(1) << "dropCollection " << nss.ns() << " completed"; + LOGV2_DEBUG(21928, 1, "dropCollection {nss_ns} completed", "nss_ns"_attr = nss.ns()); ShardingLogging::get(opCtx)->logChange( opCtx, "dropCollection", nss.ns(), BSONObj(), ShardingCatalogClient::kMajorityWriteConcern); @@ -455,8 +458,10 @@ void ShardingCatalogManager::dropCollection(OperationContext* opCtx, const Names void ShardingCatalogManager::ensureDropCollectionCompleted(OperationContext* opCtx, const NamespaceString& nss) { - LOG(1) << "Ensuring config entries for " << nss.ns() - << " from previous dropCollection are cleared"; + LOGV2_DEBUG(21929, + 1, + "Ensuring config entries for {nss_ns} from previous dropCollection are cleared", + "nss_ns"_attr = nss.ns()); sendDropCollectionToAllShards(opCtx, nss); removeChunksAndTagsForDroppedCollection(opCtx, nss); sendSSVToAllShards(opCtx, nss); @@ -479,7 +484,7 @@ void ShardingCatalogManager::generateUUIDsForExistingShardedCollections(Operatio .docs; if (shardedColls.empty()) { - LOG(0) << "all sharded collections already have UUIDs"; + LOGV2(21930, "all sharded collections already have UUIDs"); // We did a local read of the collections collection above and found that all sharded // collections already have UUIDs. However, the data may not be majority committed (a @@ -491,8 +496,10 @@ void ShardingCatalogManager::generateUUIDsForExistingShardedCollections(Operatio } // Generate and persist a new UUID for each collection that did not have a UUID. - LOG(0) << "generating UUIDs for " << shardedColls.size() - << " sharded collections that do not yet have a UUID"; + LOGV2( + 21931, + "generating UUIDs for {shardedColls_size} sharded collections that do not yet have a UUID", + "shardedColls_size"_attr = shardedColls.size()); for (auto& coll : shardedColls) { auto collType = uassertStatusOK(CollectionType::fromBSON(coll)); invariant(!collType.getUUID()); @@ -502,8 +509,12 @@ void ShardingCatalogManager::generateUUIDsForExistingShardedCollections(Operatio uassertStatusOK(ShardingCatalogClientImpl::updateShardingCatalogEntryForCollection( opCtx, collType.getNs(), collType, false /* upsert */)); - LOG(2) << "updated entry in config.collections for sharded collection " << collType.getNs() - << " with generated UUID " << uuid; + LOGV2_DEBUG(21932, + 2, + "updated entry in config.collections for sharded collection {collType_getNs} " + "with generated UUID {uuid}", + "collType_getNs"_attr = collType.getNs(), + "uuid"_attr = uuid); } } @@ -617,9 +628,12 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, true /* startTransaction */, txnNumber)); - log() << "refineCollectionShardKey: updated collection entry for '" << nss.ns() - << "': took " << executionTimer.millis() - << " ms. Total time taken: " << totalTimer.millis() << " ms."; + LOGV2(21933, + "refineCollectionShardKey: updated collection entry for '{nss_ns}': took " + "{executionTimer_millis} ms. Total time taken: {totalTimer_millis} ms.", + "nss_ns"_attr = nss.ns(), + "executionTimer_millis"_attr = executionTimer.millis(), + "totalTimer_millis"_attr = totalTimer.millis()); executionTimer.reset(); // Update all config.chunks entries for the given namespace by setting (i) their epoch to @@ -627,7 +641,7 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, // MinKey (except for the global max chunk where the max bounds are set to MaxKey), and // unsetting (iii) their jumbo field. if (MONGO_unlikely(hangRefineCollectionShardKeyBeforeUpdatingChunks.shouldFail())) { - log() << "Hit hangRefineCollectionShardKeyBeforeUpdatingChunks failpoint"; + LOGV2(21934, "Hit hangRefineCollectionShardKeyBeforeUpdatingChunks failpoint"); hangRefineCollectionShardKeyBeforeUpdatingChunks.pauseWhileSet(opCtx); } @@ -653,9 +667,12 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, false, // startTransaction txnNumber)); - log() << "refineCollectionShardKey: updated chunk entries for '" << nss.ns() << "': took " - << executionTimer.millis() << " ms. Total time taken: " << totalTimer.millis() - << " ms."; + LOGV2(21935, + "refineCollectionShardKey: updated chunk entries for '{nss_ns}': took " + "{executionTimer_millis} ms. Total time taken: {totalTimer_millis} ms.", + "nss_ns"_attr = nss.ns(), + "executionTimer_millis"_attr = executionTimer.millis(), + "totalTimer_millis"_attr = totalTimer.millis()); executionTimer.reset(); // Update all config.tags entries for the given namespace by setting their bounds for each @@ -680,12 +697,15 @@ void ShardingCatalogManager::refineCollectionShardKey(OperationContext* opCtx, false, // startTransaction txnNumber)); - log() << "refineCollectionShardKey: updated zone entries for '" << nss.ns() << "': took " - << executionTimer.millis() << " ms. Total time taken: " << totalTimer.millis() - << " ms."; + LOGV2(21936, + "refineCollectionShardKey: updated zone entries for '{nss_ns}': took " + "{executionTimer_millis} ms. Total time taken: {totalTimer_millis} ms.", + "nss_ns"_attr = nss.ns(), + "executionTimer_millis"_attr = executionTimer.millis(), + "totalTimer_millis"_attr = totalTimer.millis()); if (MONGO_unlikely(hangRefineCollectionShardKeyBeforeCommit.shouldFail())) { - log() << "Hit hangRefineCollectionShardKeyBeforeCommit failpoint"; + LOGV2(21937, "Hit hangRefineCollectionShardKeyBeforeCommit failpoint"); hangRefineCollectionShardKeyBeforeCommit.pauseWhileSet(opCtx); } diff --git a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp index 4028d41a34d..c46a65966a7 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_database_operations.cpp @@ -39,6 +39,7 @@ #include "mongo/db/repl/repl_client_info.h" #include "mongo/db/server_options.h" #include "mongo/db/write_concern.h" +#include "mongo/logv2/log.h" #include "mongo/s/catalog/type_database.h" #include "mongo/s/catalog_cache.h" #include "mongo/s/client/shard.h" @@ -150,7 +151,7 @@ DatabaseType ShardingCatalogManager::createDatabase(OperationContext* opCtx, // Pick a primary shard for the new database. DatabaseType db(dbName.toString(), shardPtr->getId(), false, databaseVersion::makeNew()); - log() << "Registering new database " << db << " in sharding catalog"; + LOGV2(21938, "Registering new database {db} in sharding catalog", "db"_attr = db); // Do this write with majority writeConcern to guarantee that the shard sees the write when it // receives the _flushDatabaseCacheUpdates. @@ -214,7 +215,7 @@ void ShardingCatalogManager::enableSharding(OperationContext* opCtx, Milliseconds{30000}), &unusedResult)); - log() << "Enabling sharding for database [" << dbName << "] in config db"; + LOGV2(21939, "Enabling sharding for database [{dbName}] in config db", "dbName"_attr = dbName); uassertStatusOK(Grid::get(opCtx)->catalogClient()->updateConfigDocument( opCtx, @@ -303,8 +304,10 @@ Status ShardingCatalogManager::commitMovePrimary(OperationContext* opCtx, ShardingCatalogClient::kLocalWriteConcern); if (!updateStatus.isOK()) { - log() << "error committing movePrimary: " << dbname - << causedBy(redact(updateStatus.getStatus())); + LOGV2(21940, + "error committing movePrimary: {dbname}{causedBy_updateStatus_getStatus}", + "dbname"_attr = dbname, + "causedBy_updateStatus_getStatus"_attr = causedBy(redact(updateStatus.getStatus()))); return updateStatus.getStatus(); } diff --git a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp index c388e826010..b2148656e52 100644 --- a/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp +++ b/src/mongo/db/s/config/sharding_catalog_manager_shard_operations.cpp @@ -59,6 +59,7 @@ #include "mongo/db/s/type_shard_identity.h" #include "mongo/db/wire_version.h" #include "mongo/executor/task_executor.h" +#include "mongo/logv2/log.h" #include "mongo/rpc/get_status_from_command_result.h" #include "mongo/s/catalog/config_server_version.h" #include "mongo/s/catalog/sharding_catalog_client.h" @@ -161,7 +162,9 @@ StatusWith<Shard::CommandResponse> ShardingCatalogManager::_runCommandForAddShar _executorForAddShard->wait(swCallbackHandle.getValue()); if (response.status == ErrorCodes::ExceededTimeLimit) { - LOG(0) << "Operation timed out with status " << redact(response.status); + LOGV2(21941, + "Operation timed out with status {response_status}", + "response_status"_attr = redact(response.status)); } if (!response.isOK()) { @@ -672,7 +675,9 @@ StatusWith<std::string> ShardingCatalogManager::addShard( return versionResponse.getValue().commandStatus; } - log() << "going to insert new entry for shard into config.shards: " << shardType.toString(); + LOGV2(21942, + "going to insert new entry for shard into config.shards: {shardType}", + "shardType"_attr = shardType.toString()); Status result = Grid::get(opCtx)->catalogClient()->insertConfigDocument( opCtx, @@ -680,7 +685,10 @@ StatusWith<std::string> ShardingCatalogManager::addShard( shardType.toBSON(), ShardingCatalogClient::kLocalWriteConcern); if (!result.isOK()) { - log() << "error adding shard: " << shardType.toBSON() << " err: " << result.reason(); + LOGV2(21943, + "error adding shard: {shardType} err: {result_reason}", + "shardType"_attr = shardType.toBSON(), + "result_reason"_attr = result.reason()); return result; } } @@ -698,8 +706,11 @@ StatusWith<std::string> ShardingCatalogManager::addShard( true, ShardingCatalogClient::kLocalWriteConcern); if (!status.isOK()) { - log() << "adding shard " << shardConnectionString.toString() - << " even though could not add database " << dbName; + LOGV2(21944, + "adding shard {shardConnectionString} even though could not add database " + "{dbName}", + "shardConnectionString"_attr = shardConnectionString.toString(), + "dbName"_attr = dbName); } } } @@ -773,7 +784,7 @@ RemoveShardProgress ShardingCatalogManager::removeShard(OperationContext* opCtx, auto* const catalogClient = Grid::get(opCtx)->catalogClient(); if (!isShardCurrentlyDraining) { - log() << "going to start draining shard: " << name; + LOGV2(21945, "going to start draining shard: {name}", "name"_attr = name); // Record start in changelog uassertStatusOK(ShardingLogging::get(opCtx)->logChangeChecked( @@ -811,9 +822,9 @@ RemoveShardProgress ShardingCatalogManager::removeShard(OperationContext* opCtx, if (chunkCount > 0 || databaseCount > 0) { // Still more draining to do - LOG(0) << "chunkCount: " << chunkCount; - LOG(0) << "databaseCount: " << databaseCount; - LOG(0) << "jumboCount: " << jumboCount; + LOGV2(21946, "chunkCount: {chunkCount}", "chunkCount"_attr = chunkCount); + LOGV2(21947, "databaseCount: {databaseCount}", "databaseCount"_attr = databaseCount); + LOGV2(21948, "jumboCount: {jumboCount}", "jumboCount"_attr = jumboCount); return {RemoveShardProgress::ONGOING, boost::optional<RemoveShardProgress::DrainingShardUsage>( @@ -821,7 +832,7 @@ RemoveShardProgress ShardingCatalogManager::removeShard(OperationContext* opCtx, } // Draining is done, now finish removing the shard. - log() << "going to remove shard: " << name; + LOGV2(21949, "going to remove shard: {name}", "name"_attr = name); audit::logRemoveShard(opCtx->getClient(), name); uassertStatusOKWithContext( |