Skip to content

Commit 5de08c6

Browse files
committed
jobs: respect server queiscing in maybeDumpTrace
Previously, we ignored the context cancellation function in `maybeDumpTrace` that is returned by `makeCtx`, which made it so that we could stuck indefinitely on the server shutdown. We now include the cancellation function to be called on Queisce. Release note: None
1 parent f37e9c2 commit 5de08c6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/jobs/adopt.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ func (r *Registry) maybeDumpTrace(resumerCtx context.Context, resumer Resumer, j
6969
return
7070
}
7171

72-
// Make a new ctx to use in the trace dumper. This is because the resumerCtx
73-
// could have been canceled at this point.
74-
dumpCtx, _ := r.makeCtx()
7572
sp := tracing.SpanFromContext(resumerCtx)
7673
if sp == nil {
7774
// Should never be true since TraceableJobs force real tracing spans to be
@@ -82,8 +79,13 @@ func (r *Registry) maybeDumpTrace(resumerCtx context.Context, resumer Resumer, j
8279
resumerTraceFilename := fmt.Sprintf("%s/resumer-trace/%s",
8380
timeutil.Now().Format("20060102_150405.00"), r.ID().String())
8481
td := jobspb.TraceData{CollectedSpans: sp.GetConfiguredRecording()}
82+
83+
// Make a new ctx to use in the trace dumper. This is because the resumerCtx
84+
// could have been canceled at this point.
85+
dumpCtx, cancel := r.makeCtx()
86+
r.stopper.OnQuiesce(cancel)
8587
if err := r.db.Txn(dumpCtx, func(ctx context.Context, txn isql.Txn) error {
86-
return WriteProtobinExecutionDetailFile(dumpCtx, resumerTraceFilename, &td, txn, jobID)
88+
return WriteProtobinExecutionDetailFile(ctx, resumerTraceFilename, &td, txn, jobID)
8789
}); err != nil {
8890
log.Dev.Warningf(dumpCtx, "failed to write trace on resumer trace file: %v", err)
8991
}

0 commit comments

Comments
 (0)