Skip to content

Commit 1c5f235

Browse files
craig[bot]spilchen
craig[bot]
andcommitted
Merge #146362
146362: sql/distsql: preserve JobID in redacted logs r=spilchen a=spilchen Previously, the JobID log tag could be redacted, making it difficult to trace TTL job execution when viewing redacted logs. This change ensures the JobID is logged as a redact.SafeString, allowing it to appear in redacted outputs for easier debugging. Additionally, the flowCtx.ID is now also saved as a safe string too. Epic: none Release note: none Co-authored-by: Matt Spilchen <[email protected]>
2 parents 30d25d2 + 80a7e7d commit 1c5f235

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

pkg/sql/distsql/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ func (ds *ServerImpl) setupFlow(
384384

385385
if !f.IsLocal() {
386386
bld := logtags.BuildBuffer()
387-
bld.Add("f", flowCtx.ID.Short().String())
387+
bld.Add("f", flowCtx.ID.Short())
388388
if req.JobTag != "" {
389389
bld.Add("job", req.JobTag)
390390
}

pkg/sql/distsql_running.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import (
6060
"github.com/cockroachdb/cockroach/pkg/util/tracing"
6161
"github.com/cockroachdb/errors"
6262
"github.com/cockroachdb/logtags"
63+
"github.com/cockroachdb/redact"
6364
)
6465

6566
var settingDistSQLNumRunners = settings.RegisterIntSetting(
@@ -467,7 +468,7 @@ func (dsp *DistSQLPlanner) setupFlows(
467468
// In distributed plans populate some extra state.
468469
setupReq.EvalContext = execinfrapb.MakeEvalContext(evalCtx)
469470
if jobTag, ok := logtags.FromContext(ctx).GetTag("job"); ok {
470-
setupReq.JobTag = jobTag.ValueStr()
471+
setupReq.JobTag = redact.SafeString(jobTag.ValueStr())
471472
}
472473
}
473474
if evalCtx.SessionData().PropagateAdmissionHeaderToLeafTransactions && localState.Txn != nil {

pkg/sql/execinfrapb/api.proto

+2-1
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)