Skip to content

Commit

Permalink
jobs: move trace_id from payload to progress
Browse files Browse the repository at this point in the history
The trace_id associated with a job is updated on every
resumption of the job. If the job is paused and resumed
several times, we don't want to rewrite the payload every
single time. Thus, we move the field to the job progress
which is expected to be rewritten frequently.

Also addresses a comment from cockroachdb#65322.

Release note: None
  • Loading branch information
adityamaru committed May 19, 2021
1 parent 35789fc commit c9599e9
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 359 deletions.
10 changes: 4 additions & 6 deletions pkg/jobs/adopt.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,15 @@ func (r *Registry) runJob(
//
// A new root span will be created on every resumption of the job.
var spanOptions []tracing.SpanOption
if tj, ok := resumer.(TraceableJob); ok {
if tj.ForceRealSpan() {
spanOptions = append(spanOptions, tracing.WithForceRealSpan())
}
if _, ok := resumer.(TraceableJob); ok {
spanOptions = append(spanOptions, tracing.WithForceRealSpan())
}
ctx, span = r.settings.Tracer.StartSpanCtx(ctx, spanName, spanOptions...)
defer span.Finish()
if err := job.Update(ctx, nil /* txn */, func(txn *kv.Txn, md JobMetadata,
ju *JobUpdater) error {
md.Payload.TraceID = span.TraceID()
ju.UpdatePayload(md.Payload)
md.Progress.TraceID = span.TraceID()
ju.UpdateProgress(md.Progress)
return nil
}); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/jobs/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type StartableJob struct {
type TraceableJob interface {
// ForceRealSpan forces the registry to create a real Span instead of a
// low-overhead non-recordable noop span.
ForceRealSpan() bool
ForceRealSpan()
}

func init() {
Expand Down
Loading

0 comments on commit c9599e9

Please sign in to comment.