Skip to content

fix: Backport WAL replay hang fix to release-3.6.x (#21176) - #23630

Merged
jnewbigin merged 3 commits into
release-3.6.xfrom
backport/21176-to-release-3.6.x
Jul 31, 2026
Merged

fix: Backport WAL replay hang fix to release-3.6.x (#21176)#23630
jnewbigin merged 3 commits into
release-3.6.xfrom
backport/21176-to-release-3.6.x

Conversation

@spiridonov

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Backports the WAL replay no-progress fix to release-3.6.x so it can be picked up by GEL 3.6 (which vendors this branch).

On 3.6.x, replayController.WithBackPressure has no exit condition: if a replay-triggered flush does not reduce in-memory bytes below 90% of replay_memory_ceiling (slow/unavailable storage backend, chunk_retain_period holding freshly flushed chunks, failed immediate flush ops being re-enqueued forever), the ingester spins in the backpressure loop indefinitely. It never finishes replay, never becomes ready, gets killed by the startup probe, and replays the same WAL again on the next start — an unrecoverable crash loop that only clearing the WAL breaks. We hit exactly this with a customer running GEL 3.6.10 (grafana/support-escalations#23469).

Two cherry-picks, in order:

The refactor is included because #21176 was written on top of it; taking both keeps replay_controller.go identical to main (both cherry-picks applied cleanly, no conflicts) instead of hand-porting the progress-detection logic onto the old sync.Cond implementation.

With this fix, a no-progress flush fails recovery with an explicit error (WAL replay flush made no progress: ... cannot recover) instead of hanging silently, and a zero replay_memory_ceiling no longer triggers backpressure on every record.

Special notes for your reviewer:

go test ./pkg/ingester/ -run TestReplayController passes on this branch, including the four tests added by #21176.

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory.

🤖 Generated with Claude Code

Segflow and others added 2 commits July 28, 2026 14:01
@spiridonov
spiridonov requested a review from a team as a code owner July 28, 2026 18:03

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 987b6f1. Configure here.

Comment thread pkg/ingester/replay_controller.go
@jnewbigin jnewbigin self-assigned this Jul 31, 2026
@jnewbigin

Copy link
Copy Markdown
Contributor

I'll cherry-pick #23631 into this PR

…ight replay flush

Return the number of bytes subtracted from within the singleflight-protected
flush, so every caller coalesced into that flush observes its progress, and
only treat a zero-progress flush as fatal while still over the ceiling.

WithBackPressure sampled totalSubtracted outside the singleflight window.
A worker that loaded the counter after an in-flight flush had already called
Sub, then joined that same flush, saw no change to the counter and aborted WAL
recovery with "flush made no progress" even though the flush had freed memory.

Cherry-picked from #23631 so that release-3.6.x does not pick up the race along
with the WAL replay hang fix.
@jnewbigin
jnewbigin enabled auto-merge (squash) July 31, 2026 05:25
@jnewbigin
jnewbigin merged commit 355e2f3 into release-3.6.x Jul 31, 2026
80 checks passed
@jnewbigin
jnewbigin deleted the backport/21176-to-release-3.6.x branch July 31, 2026 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

4 participants