Skip to content

Fix message store crash when file deleted during concurrent GC (backport #15411)#15426

Merged
michaelklishin merged 1 commit intov4.2.xfrom
mergify/bp/v4.2.x/pr-15411
Feb 9, 2026
Merged

Fix message store crash when file deleted during concurrent GC (backport #15411)#15426
michaelklishin merged 1 commit intov4.2.xfrom
mergify/bp/v4.2.x/pr-15411

Conversation

@mergify
Copy link
Copy Markdown

@mergify mergify bot commented Feb 9, 2026

During high load operations (such as maintenance drain with heavy queue leadership transfers), the message store can crash with {case_clause, {false, []}} in write_action/3 at line 1121.

This occurs when:

  1. A message exists in the index with ref_count=0 referencing file N
  2. File N is marked for deletion (valid_total_size=0)
  3. The garbage collector asynchronously deletes file N from FileSummaryEts
  4. A write operation attempts to look up file N
  5. ets:lookup(FileSummaryEts, N) returns []
  6. No case clause matches {false, []}

The crash cascades to queue processes attempting to write messages.

Solution

Add two new case clauses to write_action/3 to handle files already deleted by GC:

  • {false, []} - Delete stale index entry and write fresh copy to current file
  • {false_if_increment, []} - Ignore write when client is dying

This follows the same pattern as existing clauses that handle files being deleted or locked. Since ref_count=0, the old copy is orphaned and should be safe to discard.


This is an automatic backport of pull request #15411 done by Mergify.

Handle case where garbage collector asynchronously deletes a file from
FileSummaryEts while a write operation is trying to reference it. This
race condition can occur during high load (e.g., maintenance drain with
heavy queue leadership transfers) when:

1. Message exists in index with ref_count=0, file=N
2. File N is marked for deletion (valid_total_size=0)
3. GC asynchronously deletes file N from FileSummaryEts
4. Write request arrives for the message
5. ets:lookup(FileSummaryEts, N) returns []
6. Code crashes with {case_clause, {false, []}}

The fix adds two new case clauses to handle this scenario:

- {false, []} - Delete stale index entry and write fresh copy
- {false_if_increment, []} - Ignore write (client dying)

This follows the same pattern as existing clauses that handle files
being deleted or locked. Since ref_count=0, the old copy is orphaned
and safe to discard.

Observed in production during maintenance window causing 969 queue
process crashes. See ticket V2090892319.

(cherry picked from commit 8f27887)
@michaelklishin michaelklishin added this to the 4.2.4 milestone Feb 9, 2026
@michaelklishin michaelklishin merged commit ede699f into v4.2.x Feb 9, 2026
1138 of 1149 checks passed
@michaelklishin michaelklishin deleted the mergify/bp/v4.2.x/pr-15411 branch February 9, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants