Skip to content

Commit c8034bb

Browse files
HanaPearlmanMongoDB Bot
authored andcommitted
SERVER-98720: Add missing redact() calls to query logs (#33183)
GitOrigin-RevId: 2d57d2ecc560faa5da609936c4159fe5f64915b6
1 parent 268eba9 commit c8034bb

12 files changed

+18
-17
lines changed

src/mongo/db/commands/distinct.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ class DistinctCommand : public BasicCommand {
341341
"Plan executor error during distinct command",
342342
"error"_attr = exception.toStatus(),
343343
"stats"_attr = redact(stats),
344-
"cmd"_attr = cmdObj);
344+
"cmd"_attr = redact(cmdObj));
345345

346346
exception.addContext("Executor error during distinct command");
347347
throw;

src/mongo/db/commands/find_cmd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ class FindCmd final : public Command {
666666
"Plan executor error during find command",
667667
"error"_attr = exception.toStatus(),
668668
"stats"_attr = redact(stats),
669-
"cmd"_attr = cmdObj);
669+
"cmd"_attr = redact(cmdObj));
670670

671671
exception.addContext("Executor error during find command");
672672
throw;

src/mongo/db/commands/getmore_cmd.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class GetMoreCmd final : public Command {
441441
"getMore command executor error",
442442
"error"_attr = exception.toStatus(),
443443
"stats"_attr = redact(stats),
444-
"cmd"_attr = cmd.toBSON({}));
444+
"cmd"_attr = redact(cmd.toBSON({})));
445445

446446
exception.addContext("Executor error during getMore");
447447
throw;

src/mongo/db/commands/run_aggregate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ bool handleCursorCommand(OperationContext* opCtx,
231231
"Aggregate command executor error",
232232
"error"_attr = exception.toStatus(),
233233
"stats"_attr = redact(stats),
234-
"cmd"_attr = cmdObj);
234+
"cmd"_attr = redact(cmdObj));
235235

236236
exception.addContext("PlanExecutor error during aggregation");
237237
throw;

src/mongo/db/query/classic_stage_builder.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ std::unique_ptr<PlanStage> ClassicStageBuilder::build(const QuerySolutionNode* r
428428
case STAGE_SENTINEL:
429429
case STAGE_COLUMN_SCAN:
430430
case STAGE_UPDATE: {
431-
LOGV2_WARNING(4615604, "Can't build exec tree for node", "node"_attr = *root);
431+
LOGV2_WARNING(
432+
4615604, "Can't build exec tree for node", "node"_attr = redact(root->toString()));
432433
}
433434
}
434435

src/mongo/db/query/expression_index.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void ExpressionMapping::S2CellIdsToIntervals(const std::vector<S2CellId>& interv
182182
if (!oilOut->isValidFor(1)) {
183183
LOGV2(6029801,
184184
"invalid OrderedIntervalList",
185-
"orderedIntervalList"_attr = oilOut->toString(false));
185+
"orderedIntervalList"_attr = redact(oilOut->toString(false)));
186186
MONGO_UNREACHABLE;
187187
}
188188
}
@@ -231,7 +231,7 @@ void ExpressionMapping::S2CellIdsToIntervalsWithParents(const std::vector<S2Cell
231231
if (!oilOut->isValidFor(1)) {
232232
LOGV2(6029802,
233233
"invalid OrderedIntervalList",
234-
"orderedIntervalList"_attr = oilOut->toString(false));
234+
"orderedIntervalList"_attr = redact(oilOut->toString(false)));
235235
MONGO_UNREACHABLE;
236236
}
237237
}

src/mongo/db/query/plan_enumerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ unique_ptr<MatchExpression> PlanEnumerator::getNext() {
384384
tagForSort(tree.get());
385385

386386
_root->resetTag();
387-
LOGV2_DEBUG(20943, 5, "Enumerator: memo just before moving", "memo"_attr = dumpMemo());
387+
LOGV2_DEBUG(20943, 5, "Enumerator: memo just before moving", "memo"_attr = redact(dumpMemo()));
388388
_done = nextMemo(memoIDForNode(_root));
389389
return tree;
390390
}

src/mongo/db/query/plan_executor_factory.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> make(
139139
LOGV2_DEBUG(4822860,
140140
5,
141141
"SBE plan",
142-
"slots"_attr = data.debugString(),
143-
"stages"_attr = sbe::DebugPrinter{}.print(*rootStage));
142+
"slots"_attr = redact(data.debugString()),
143+
"stages"_attr = redact(sbe::DebugPrinter{}.print(*rootStage)));
144144

145145
return {{new PlanExecutorSBE(
146146
opCtx,
@@ -173,8 +173,8 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> make(
173173
LOGV2_DEBUG(4822861,
174174
5,
175175
"SBE plan",
176-
"slots"_attr = candidates.winner().data.stageData.debugString(),
177-
"stages"_attr = sbe::DebugPrinter{}.print(*candidates.winner().root));
176+
"slots"_attr = redact(candidates.winner().data.stageData.debugString()),
177+
"stages"_attr = redact(sbe::DebugPrinter{}.print(*candidates.winner().root)));
178178

179179
return {{new PlanExecutorSBE(opCtx,
180180
std::move(cq),

src/mongo/db/query/planner_ixselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ bool QueryPlannerIXSelect::_compatible(const BSONElement& keyPatternElt,
659659
} else {
660660
LOGV2_WARNING(20954,
661661
"Unknown indexing for given node and field",
662-
"node"_attr = node->debugString(),
662+
"node"_attr = redact(node->debugString()),
663663
"field"_attr = keyPatternElt.toString());
664664
MONGO_verify(0);
665665
}

src/mongo/db/query/query_stats/query_stats.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void registerRequest(OperationContext* opCtx,
301301
"Error encountered when creating the Query Stats store key. Metrics will not "
302302
"be collected for this command",
303303
"status"_attr = status,
304-
"command"_attr = cmdObj);
304+
"command"_attr = redact(cmdObj));
305305
if (kDebugBuild || internalQueryStatsErrorsAreCommandFatal.load()) {
306306
// uassert rather than tassert so that we avoid creating fatal failures on queries that
307307
// were going to fail anyway, but trigger the error here first. A query that ONLY fails

0 commit comments

Comments
 (0)