fix(generators): own backoff timing in the worker to fix ExponentialBackOff data race (PIPE-1222) - #269
Open
Dylan-M wants to merge 1 commit into
Open
Conversation
…ponentialBackOff data race (PIPE-1222) Assisted-by: Claude Opus 4.8
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Proposed Change
Every generator built its send loop with
backoff.NewTicker(backoffConfig)and also calledbackoffConfig.Reset()from the worker goroutine.NewTickerruns its own goroutine that repeatedly callsNextBackOff(), so two goroutines mutated onebackoff.ExponentialBackOff, which is not safe for concurrent use. That is a data race on the backoff's interval state.This drops
backoff.NewTickerand drives the interval from atime.Timerowned by the worker. Only the worker callsNextBackOff()andReset()now, so the backoff state has a single owner. Emission cadence and the reset-on-success behavior are unchanged.Applied to all 12 generators that shared the pattern: json, apache, apache_combined, apache_error, nginx, filegen, okta, paloalto, postgres, kubernetes, wel, winevt.
How to validate
go test -race ./generator/...passes. Those suites were the failing signal before this change (they reported theReset()vsNextBackOff()race under-race).mainand this branch (e.g.blitz --config <json config>) and confirm the output cadence is unchanged.Checklist