Skip to content

fix(durablejobs): preserve job state across retries - #10349

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:reubenbond-fix-durable-jobs-trace-id
Aug 7, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:reubenbond-fix-durable-jobs-trace-id

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 7, 2026

Copy link
Copy Markdown
Member

Durable job retries reconstructed the queued job without copying its persisted W3C trace context, so a retried execution could start an unrelated trace.

Preserve trace context when rescheduling in-memory jobs. Also pass the complete DurableJob and IJobRunContext through the public JobShard persistence hooks so custom persistent shards cannot lose trace fields or dequeue state across reloads and reassignment. Add focused coverage for both paths.

Copilot AI review requested due to automatic review settings August 7, 2026 01:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a tracing continuity bug in the durable jobs in-memory queue by ensuring W3C trace context (both traceparent and tracestate) is preserved when a queued job is rescheduled for retry. This aligns retry behavior with the persisted job data so subsequent attempts continue the original distributed trace.

Changes:

  • Copy TraceParent and TraceState when reconstructing a job during RetryJobLater rescheduling.
  • Add a focused regression test to verify trace context is preserved across retry rescheduling.
  • Extend the test helper CreateJob to allow specifying trace context fields.
Show a summary per file
File Description
src/Orleans.DurableJobs/InMemoryJobQueue.cs Preserves TraceParent/TraceState when rebuilding a job during retry rescheduling.
test/Orleans.Core.Tests/DurableJobs/InMemoryJobQueueTests.cs Adds regression coverage for trace context preservation and updates the job factory helper to set trace fields.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@ReubenBond ReubenBond changed the title fix(durablejobs): preserve trace context on retry fix(durablejobs): preserve job state across retries Aug 7, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ae52f9-a827-4bf4-a4b6-3bf69b7e7631
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 14ae52f9-a827-4bf4-a4b6-3bf69b7e7631
@ReubenBond
ReubenBond force-pushed the reubenbond-fix-durable-jobs-trace-id branch from 169d85a to 356bd5f Compare August 7, 2026 15:42
@ReubenBond
ReubenBond merged commit 29e32bb into dotnet:main Aug 7, 2026
66 of 67 checks passed
@ReubenBond
ReubenBond deleted the reubenbond-fix-durable-jobs-trace-id branch August 7, 2026 17:37
This was referenced Aug 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants