Skip to content

Commit 99cfb5b

Browse files
committed
kvprober: log traced planning query
This commit adds a cluster setting kv.prober.log_tracing_on_plan_failure.enabled. If enabled, along with kv.prober.tracing.enabled, the read/write probers will log the traced planning query (targetting Meta2) if there is an error in the planning phase. Epic: None Release note: None
1 parent e4db2dd commit 99cfb5b

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pkg/kv/kvprober/kvprober.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ func (p *Prober) readProbeImpl(ctx context.Context, ops proberOpsI, txns proberT
368368
var probeCtx = ctx
369369

370370
isTracingEnabled := tracingEnabled.Get(&p.settings.SV)
371+
logTracingOnPlanFailureEnabled := isTracingEnabled && logTracingOnPlanFailureEnabled.Get(&p.settings.SV)
371372
if isTracingEnabled {
372373
probeCtx, finishAndGetRecording = tracing.ContextWithRecordingSpan(ctx, p.tracer, "read probe")
373374
}
@@ -380,7 +381,11 @@ func (p *Prober) readProbeImpl(ctx context.Context, ops proberOpsI, txns proberT
380381
if errorIsExpectedDuringNormalOperation(err) {
381382
log.Health.Warningf(ctx, "making a plan failed with expected error: %v", err)
382383
} else {
383-
log.Health.Errorf(ctx, "can't make a plan: %v", err)
384+
if logTracingOnPlanFailureEnabled {
385+
log.Health.Errorf(ctx, "can't make a plan: %v, recorded trace: %s", err, finishAndGetRecording())
386+
} else {
387+
log.Health.Errorf(ctx, "can't make a plan: %v", err)
388+
}
384389
p.metrics.ProbePlanFailures.Inc(1)
385390
}
386391
return
@@ -453,6 +458,7 @@ func (p *Prober) writeProbeImpl(ctx context.Context, ops proberOpsI, txns prober
453458
var probeCtx = ctx
454459

455460
isTracingEnabled := tracingEnabled.Get(&p.settings.SV)
461+
logTracingOnPlanFailureEnabled := isTracingEnabled && logTracingOnPlanFailureEnabled.Get(&p.settings.SV)
456462
if isTracingEnabled {
457463
probeCtx, finishAndGetRecording = tracing.ContextWithRecordingSpan(ctx, p.tracer, "write probe")
458464
}
@@ -467,7 +473,11 @@ func (p *Prober) writeProbeImpl(ctx context.Context, ops proberOpsI, txns prober
467473
if errorIsExpectedDuringNormalOperation(err) {
468474
log.Health.Warningf(ctx, "making a plan failed with expected error: %v", err)
469475
} else {
470-
log.Health.Errorf(ctx, "can't make a plan: %v", err)
476+
if logTracingOnPlanFailureEnabled {
477+
log.Health.Errorf(ctx, "can't make a plan: %v, recorded trace: %s", err, finishAndGetRecording())
478+
} else {
479+
log.Health.Errorf(ctx, "can't make a plan: %v", err)
480+
}
471481
p.metrics.ProbePlanFailures.Inc(1)
472482
}
473483
return

pkg/kv/kvprober/settings.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,10 @@ var tracingEnabled = settings.RegisterBoolSetting(
136136
"whether the KV prober should collect traces, in order to log info about"+
137137
"leaseholders of ranges probed",
138138
false)
139+
140+
var logTracingOnPlanFailureEnabled = settings.RegisterBoolSetting(
141+
settings.ApplicationLevel,
142+
"kv.prober.log_tracing_on_plan_failure.enabled",
143+
"whether the KV prober should print log traces when planning fails; "+
144+
"requires kv.prober.tracing.enabled to be set to true",
145+
false)

0 commit comments

Comments
 (0)