Skip to content

Commit 2e75789

Browse files
authored
Merge pull request #146467 from spilchen/backport24.3-146362
release-24.3: sql/distsql: preserve JobID in redacted logs
2 parents 273e870 + 2520baf commit 2e75789

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pkg/sql/distsql/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func (ds *ServerImpl) setupFlow(
368368
}
369369

370370
if !f.IsLocal() {
371-
flowCtx.AmbientContext.AddLogTag("f", flowCtx.ID.Short())
371+
flowCtx.AmbientContext.AddLogTag("f", redact.SafeString(flowCtx.ID.Short()))
372372
if req.JobTag != "" {
373373
flowCtx.AmbientContext.AddLogTag("job", req.JobTag)
374374
}

pkg/sql/distsql_running.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import (
5454
"github.com/cockroachdb/cockroach/pkg/util/tracing"
5555
"github.com/cockroachdb/errors"
5656
"github.com/cockroachdb/logtags"
57+
"github.com/cockroachdb/redact"
5758
)
5859

5960
var settingDistSQLNumRunners = settings.RegisterIntSetting(
@@ -420,7 +421,7 @@ func (dsp *DistSQLPlanner) setupFlows(
420421
// In distributed plans populate some extra state.
421422
setupReq.EvalContext = execinfrapb.MakeEvalContext(&evalCtx.Context)
422423
if jobTag, ok := logtags.FromContext(ctx).GetTag("job"); ok {
423-
setupReq.JobTag = jobTag.ValueStr()
424+
setupReq.JobTag = redact.SafeString(jobTag.ValueStr())
424425
}
425426
}
426427
if evalCtx.SessionData().PropagateAdmissionHeaderToLeafTransactions && localState.Txn != nil {

pkg/sql/execinfrapb/api.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ message SetupFlowRequest {
2727

2828
optional util.tracing.tracingpb.TraceInfo trace_info = 11;
2929
// JobTag is only populated in distributed flows.
30-
optional string job_tag = 13 [(gogoproto.nullable) = false];
30+
optional string job_tag = 13 [(gogoproto.nullable) = false,
31+
(gogoproto.casttype) = "github.com/cockroachdb/redact.SafeString"];
3132

3233
// LeafTxnInputState is the input parameter for the *kv.Txn needed for
3334
// executing the flow.

0 commit comments

Comments
 (0)