diff options
author | Cheahuychou Mao <mao.cheahuychou@gmail.com> | 2023-02-06 22:00:25 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-06 23:06:38 +0000 |
commit | 63c63511ab29416dc3658d6416ba35c7faf4a236 (patch) | |
tree | a40348347341ac934d5f11500c0976f9a83855e1 | |
parent | ea3ec1f082a7178fb2ddf0a6d67be2283f488b67 (diff) | |
download | mongo-63c63511ab29416dc3658d6416ba35c7faf4a236.tar.gz |
SERVER-73644 Fix heap-use-after-free error caused by the note field in the analyzeShardKey response
-rw-r--r-- | src/mongo/db/s/analyze_shard_key_cmd.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/mongo/db/s/analyze_shard_key_cmd.cpp b/src/mongo/db/s/analyze_shard_key_cmd.cpp index 4afe5634932..bbf5c112606 100644 --- a/src/mongo/db/s/analyze_shard_key_cmd.cpp +++ b/src/mongo/db/s/analyze_shard_key_cmd.cpp @@ -48,15 +48,12 @@ namespace { MONGO_FAIL_POINT_DEFINE(analyzeShardKeySkipCalcalutingReadWriteDistributionMetrics); -StringData makeOrphanDocsWarningMsg() { - return str::stream() << "If \"" << KeyCharacteristicsMetrics::kNumOrphanDocsFieldName - << "\" is large relative to \"" - << KeyCharacteristicsMetrics::kNumDocsFieldName - << "\", you may want to rerun the command at some other time to get more " - "accurate \"" - << KeyCharacteristicsMetrics::kNumDistinctValuesFieldName << "\" and \"" - << KeyCharacteristicsMetrics::kFrequencyFieldName << "\" metrics."; -} +const std::string kOrphanDocsWarningMessage = "If \"" + + KeyCharacteristicsMetrics::kNumOrphanDocsFieldName + "\" is large relative to \"" + + KeyCharacteristicsMetrics::kNumDocsFieldName + + "\", you may want to rerun the command at some other time to get more accurate \"" + + KeyCharacteristicsMetrics::kNumDistinctValuesFieldName + "\" and \"" + + KeyCharacteristicsMetrics::kFrequencyFieldName + "\" metrics."; void validateCommandOptions(OperationContext* opCtx, const NamespaceString& nss, @@ -99,7 +96,7 @@ public: analyze_shard_key::calculateKeyCharacteristicsMetrics(opCtx, nss, key); response.setKeyCharacteristics(keyCharacteristics); if (response.getNumOrphanDocs()) { - response.setNote(makeOrphanDocsWarningMsg()); + response.setNote(StringData(kOrphanDocsWarningMessage)); } if (!serverGlobalParams.clusterRole.isShardRole() || |