Skip to content

[FIXED] Lost sequences after hard kill in fs.removeMsgBlock of lmb#6789

Closed
MauriceVanVeen wants to merge 2 commits intomainfrom
souravagrawal/rm-blk-hard-kill
Closed

[FIXED] Lost sequences after hard kill in fs.removeMsgBlock of lmb#6789
MauriceVanVeen wants to merge 2 commits intomainfrom
souravagrawal/rm-blk-hard-kill

Conversation

@MauriceVanVeen
Copy link
Copy Markdown
Member

Supersedes #6778

Fixes an edge case where the stream state could reset during recovery in WorkQueue (WQ) streams.

In WQ streams, messages are removed immediately upon ACK. Once a message block becomes empty, NATS deletes the corresponding block file. After deleting the last message block (lmb), NATS also creates a new block file that carries the latest sequence and timestamp from lmb.

If NATS crashes between deleting the lmb and creating the new block file, on NATS reboot the recovery logic cannot restore the stream state due to the absence of any block files. This leads to a reset to sequence 0, potentially causing inconsistencies such as the consumer sequence being higher than the stream sequence.

This change updates the logic to first create the new block file before deleting the lmb. This ensures that there is always at least one valid block on disk, allowing for consistent recovery even if NATS is terminated unexpectedly during the transition.

Resolves #6600

Signed-off-by: Sourabh Agrawal souravagrawal1111@gmail.com
Signed-off-by: Maurice van Veen github@mauricevanveen.com

souravagrawal and others added 2 commits April 11, 2025 10:23
Signed-off-by: souravagrawal <souravagrawal1111@gmail.com>
Signed-off-by: Maurice van Veen <github@mauricevanveen.com>
@MauriceVanVeen MauriceVanVeen requested a review from a team as a code owner April 11, 2025 08:25
@MauriceVanVeen MauriceVanVeen deleted the souravagrawal/rm-blk-hard-kill branch April 11, 2025 08:48
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.

Consumer Sequence ahead of Stream Sequence

2 participants