Skip to content

Commit a39601e

Browse files
committed
SERVER-30841 Lower the logging verbosity in ShardServerCatalogCacheLoader
1 parent 347e5a9 commit a39601e

File tree

1 file changed

+54
-61
lines changed

1 file changed

+54
-61
lines changed

src/mongo/db/s/shard_server_catalog_cache_loader.cpp

Lines changed: 54 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ void ShardServerCatalogCacheLoader::_schedulePrimaryGetChunksSince(
669669
return;
670670
}
671671

672-
log() << "Cache loader remotely refreshed for collection " << nss << " from version "
673-
<< maxLoaderVersion << " and no metadata was found.";
672+
LOG(1) << "Cache loader remotely refreshed for collection " << nss << " from version "
673+
<< maxLoaderVersion << " and no metadata was found.";
674674
} else if (swCollectionAndChangedChunks.isOK()) {
675675
auto& collAndChunks = swCollectionAndChangedChunks.getValue();
676676

@@ -700,10 +700,10 @@ void ShardServerCatalogCacheLoader::_schedulePrimaryGetChunksSince(
700700
}
701701
}
702702

703-
log() << "Cache loader remotely refreshed for collection " << nss
704-
<< " from collection version " << maxLoaderVersion
705-
<< " and found collection version "
706-
<< collAndChunks.changedChunks.back().getVersion();
703+
LOG(1) << "Cache loader remotely refreshed for collection " << nss
704+
<< " from collection version " << maxLoaderVersion
705+
<< " and found collection version "
706+
<< collAndChunks.changedChunks.back().getVersion();
707707

708708
// Metadata was found remotely -- otherwise would have received NamespaceNotFound
709709
// rather than Status::OK(). Return metadata for CatalogCache that's GTE
@@ -755,8 +755,8 @@ void ShardServerCatalogCacheLoader::_schedulePrimaryGetDatabase(
755755
return;
756756
}
757757

758-
log() << "Cache loader remotely refreshed for database " << name
759-
<< " and found the database has been dropped.";
758+
LOG(1) << "Cache loader remotely refreshed for database " << name
759+
<< " and found the database has been dropped.";
760760

761761
} else if (swDatabaseType.isOK()) {
762762
Status scheduleStatus = _ensureMajorityPrimaryAndScheduleDbTask(
@@ -766,8 +766,8 @@ void ShardServerCatalogCacheLoader::_schedulePrimaryGetDatabase(
766766
return;
767767
}
768768

769-
log() << "Cache loader remotely refreshed for database " << name << " and found "
770-
<< swDatabaseType.getValue().toBSON();
769+
LOG(1) << "Cache loader remotely refreshed for database " << name << " and found "
770+
<< swDatabaseType.getValue().toBSON();
771771
}
772772

773773
// Complete the callbackFn work.
@@ -802,18 +802,18 @@ StatusWith<CollectionAndChangedChunks> ShardServerCatalogCacheLoader::_getLoader
802802
persisted = std::move(swPersisted.getValue());
803803
}
804804

805-
log() << "Cache loader found "
806-
<< (enqueued.changedChunks.empty()
807-
? (tasksAreEnqueued ? "a drop enqueued" : "no enqueued metadata")
808-
: ("enqueued metadata from " +
809-
enqueued.changedChunks.front().getVersion().toString() + " to " +
810-
enqueued.changedChunks.back().getVersion().toString()))
811-
<< " and " << (persisted.changedChunks.empty()
812-
? "no persisted metadata"
813-
: ("persisted metadata from " +
814-
persisted.changedChunks.front().getVersion().toString() + " to " +
815-
persisted.changedChunks.back().getVersion().toString()))
816-
<< ", GTE cache version " << catalogCacheSinceVersion;
805+
LOG(1) << "Cache loader found "
806+
<< (enqueued.changedChunks.empty()
807+
? (tasksAreEnqueued ? "a drop enqueued" : "no enqueued metadata")
808+
: ("enqueued metadata from " +
809+
enqueued.changedChunks.front().getVersion().toString() + " to " +
810+
enqueued.changedChunks.back().getVersion().toString()))
811+
<< " and " << (persisted.changedChunks.empty()
812+
? "no persisted metadata"
813+
: ("persisted metadata from " +
814+
persisted.changedChunks.front().getVersion().toString() + " to " +
815+
persisted.changedChunks.back().getVersion().toString()))
816+
<< ", GTE cache version " << catalogCacheSinceVersion;
817817

818818
if (!tasksAreEnqueued) {
819819
// There are no tasks in the queue. Return the persisted metadata.
@@ -905,10 +905,10 @@ Status ShardServerCatalogCacheLoader::_ensureMajorityPrimaryAndScheduleCollAndCh
905905

906906
Status status = _threadPool.schedule([this, nss]() { _runCollAndChunksTasks(nss); });
907907
if (!status.isOK()) {
908-
log() << "Cache loader failed to schedule persisted metadata update"
909-
<< " task for namespace '" << nss << "' due to '" << redact(status)
910-
<< "'. Clearing task list so that scheduling"
911-
<< " will be attempted by the next caller to refresh this namespace.";
908+
LOG(0) << "Cache loader failed to schedule persisted metadata update"
909+
<< " task for namespace '" << nss << "' due to '" << redact(status)
910+
<< "'. Clearing task list so that scheduling"
911+
<< " will be attempted by the next caller to refresh this namespace.";
912912

913913
_collAndChunkTaskLists.erase(nss);
914914
}
@@ -935,10 +935,10 @@ Status ShardServerCatalogCacheLoader::_ensureMajorityPrimaryAndScheduleDbTask(
935935
Status status =
936936
_threadPool.schedule([ this, name = dbName.toString() ]() { _runDbTasks(name); });
937937
if (!status.isOK()) {
938-
log() << "Cache loader failed to schedule persisted metadata update"
939-
<< " task for db '" << dbName << "' due to '" << redact(status)
940-
<< "'. Clearing task list so that scheduling"
941-
<< " will be attempted by the next caller to refresh this namespace.";
938+
LOG(0) << "Cache loader failed to schedule persisted metadata update"
939+
<< " task for db '" << dbName << "' due to '" << redact(status)
940+
<< "'. Clearing task list so that scheduling"
941+
<< " will be attempted by the next caller to refresh this namespace.";
942942

943943
_dbTaskLists.erase(dbName.toString());
944944
}
@@ -953,17 +953,13 @@ void ShardServerCatalogCacheLoader::_runCollAndChunksTasks(const NamespaceString
953953
try {
954954
_updatePersistedCollAndChunksMetadata(context.opCtx(), nss);
955955
taskFinished = true;
956+
} catch (const ExceptionForCat<ErrorCategory::ShutdownError>&) {
957+
LOG(0) << "Failed to persist chunk metadata update for collection '" << nss
958+
<< "' due to shutdown.";
959+
return;
956960
} catch (const DBException& ex) {
957-
Status exceptionStatus = ex.toStatus();
958-
959-
// This thread must stop if we are shutting down
960-
if (ErrorCodes::isShutdownError(exceptionStatus.code())) {
961-
log() << "Failed to persist chunk metadata update for collection '" << nss
962-
<< "' due to shutdown.";
963-
return;
964-
}
965-
966-
log() << redact(exceptionStatus);
961+
LOG(0) << "Failed to persist chunk metadata update for collection '" << nss
962+
<< causedBy(redact(ex));
967963
}
968964

969965
stdx::lock_guard<stdx::mutex> lock(_mutex);
@@ -977,10 +973,11 @@ void ShardServerCatalogCacheLoader::_runCollAndChunksTasks(const NamespaceString
977973
if (!_collAndChunkTaskLists[nss].empty()) {
978974
Status status = _threadPool.schedule([this, nss]() { _runCollAndChunksTasks(nss); });
979975
if (!status.isOK()) {
980-
log() << "Cache loader failed to schedule a persisted metadata update"
981-
<< " task for namespace '" << nss << "' due to '" << redact(status)
982-
<< "'. Clearing task list so that scheduling will be attempted by the next"
983-
<< " caller to refresh this namespace.";
976+
LOG(0) << "Cache loader failed to schedule a persisted metadata update"
977+
<< " task for namespace '" << nss << "' due to '" << redact(status)
978+
<< "'. Clearing task list so that scheduling will be attempted by the next"
979+
<< " caller to refresh this namespace.";
980+
984981
_collAndChunkTaskLists.erase(nss);
985982
}
986983
} else {
@@ -995,17 +992,12 @@ void ShardServerCatalogCacheLoader::_runDbTasks(StringData dbName) {
995992
try {
996993
_updatePersistedDbMetadata(context.opCtx(), dbName);
997994
taskFinished = true;
995+
} catch (const ExceptionForCat<ErrorCategory::ShutdownError>&) {
996+
LOG(0) << "Failed to persist metadata update for db '" << dbName << "' due to shutdown.";
997+
return;
998998
} catch (const DBException& ex) {
999-
Status exceptionStatus = ex.toStatus();
1000-
1001-
// This thread must stop if we are shutting down
1002-
if (ErrorCodes::isShutdownError(exceptionStatus.code())) {
1003-
log() << "Failed to persist metadata update for db '" << dbName.toString()
1004-
<< "' due to shutdown.";
1005-
return;
1006-
}
1007-
1008-
log() << redact(exceptionStatus);
999+
LOG(0) << "Failed to persist chunk metadata update for database " << dbName
1000+
<< causedBy(redact(ex));
10091001
}
10101002

10111003
stdx::lock_guard<stdx::mutex> lock(_mutex);
@@ -1017,13 +1009,14 @@ void ShardServerCatalogCacheLoader::_runDbTasks(StringData dbName) {
10171009

10181010
// Schedule more work if there is any
10191011
if (!_dbTaskLists[dbName.toString()].empty()) {
1020-
Status status = _threadPool.schedule(
1021-
[ this, name = dbName.toString() ]() { _runDbTasks(StringData(name)); });
1012+
Status status =
1013+
_threadPool.schedule([ this, name = dbName.toString() ]() { _runDbTasks(name); });
10221014
if (!status.isOK()) {
1023-
log() << "Cache loader failed to schedule a persisted metadata update"
1024-
<< " task for namespace '" << dbName.toString() << "' due to '" << redact(status)
1025-
<< "'. Clearing task list so that scheduling will be attempted by the next"
1026-
<< " caller to refresh this namespace.";
1015+
LOG(0) << "Cache loader failed to schedule a persisted metadata update"
1016+
<< " task for namespace '" << dbName << "' due to '" << redact(status)
1017+
<< "'. Clearing task list so that scheduling will be attempted by the next"
1018+
<< " caller to refresh this namespace.";
1019+
10271020
_dbTaskLists.erase(dbName.toString());
10281021
}
10291022
} else {
@@ -1099,7 +1092,7 @@ void ShardServerCatalogCacheLoader::_updatePersistedDbMetadata(OperationContext*
10991092
<< dbName.toString()
11001093
<< "'. Will be retried.");
11011094

1102-
log() << "Successfully updated persisted metadata for db '" << dbName.toString();
1095+
LOG(1) << "Successfully updated persisted metadata for db " << dbName.toString();
11031096
}
11041097

11051098
CollectionAndChangedChunks

0 commit comments

Comments
 (0)