Skip to content

Fix event batcher flush span race - #7820

Merged
pingsutw merged 1 commit into
mainfrom
fix-event-batcher-span-end
Aug 10, 2026
Merged

Fix event batcher flush span race#7820
pingsutw merged 1 commit into
mainfrom
fix-event-batcher-span-end

Conversation

@pingsutw

Copy link
Copy Markdown
Member

Summary

Fixes a timing race in eventBatcher.flush telemetry recording. The flush span was ended via defer, after callers were released through their done channel, so Record could return before the span recorder observed the ended eventBatcher.flush span.

This makes the span end explicit before notifying callers, keeping the synchronous Record contract aligned with the test expectation.

Root cause

TestEventBatcher_FlushSpanLinksCallers inspects ended spans immediately after Record returns. Because span.End() ran in a deferred call after writing to done, scheduler timing could let the test resume before the span was ended, producing zero flush spans.

Validation

  • go test ./executor/pkg/controller -run TestEventBatcher_FlushSpanLinksCallers -count=100
  • go test -race -coverprofile=coverage.out -covermode=atomic ./executor/pkg/controller
  • go test -race -coverprofile=coverage.out -covermode=atomic ./executor/...
  • go test ./executor/pkg/controller -run TestEventBatcher_FlushSpanLinksCallers -count=20

Copilot AI lite review requested due to automatic review settings August 10, 2026 20:11

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

Fixes a timing race in eventBatcher.flush span lifecycle by ensuring the flush span is ended before unblocking Record callers, aligning the synchronous Record contract with telemetry expectations.

Changes:

  • Removes deferred span ending in flush and ends the span explicitly after Record completes.
  • Ensures callers are notified (via done) only after the flush span has been ended.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pingsutw pingsutw self-assigned this Aug 10, 2026
@pingsutw
pingsutw marked this pull request as ready for review August 10, 2026 20:16
@pingsutw
pingsutw merged commit a803bdd into main Aug 10, 2026
25 checks passed
@pingsutw
pingsutw deleted the fix-event-batcher-span-end branch August 10, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants