Skip to content

fix: handle missing previous_cluster in pre_append_log_follower#600

Merged
kjnilsson merged 6 commits intorabbitmq:mainfrom
specula-org:fix/pre-append-log-follower-badkey-crash
Mar 26, 2026
Merged

fix: handle missing previous_cluster in pre_append_log_follower#600
kjnilsson merged 6 commits intorabbitmq:mainfrom
specula-org:fix/pre-append-log-follower-badkey-crash

Conversation

@Qian-Cheng-nju
Copy link
Copy Markdown
Contributor

@Qian-Cheng-nju Qian-Cheng-nju commented Mar 25, 2026

Hi, thanks for ra!

I found a crash scenario in pre_append_log_follower and put together a fix.

When a follower receives an uncommitted cluster change entry at index I, then a new leader overwrites that index with a regular entry, pre_append_log_follower crashes with {badkey, previous_cluster}. This happens because the follower path doesn't store previous_cluster in the state map when processing cluster changes, but the overwrite path assumes it's always there.

The trigger scenario: follower gets AER with cluster change at index 4 (term 5), then gets AER from a new leader overwriting index 4 with a regular entry (term 6). The second AER crashes the follower process.

@michaelklishin
Copy link
Copy Markdown
Contributor

@Qian-Cheng-nju thank you for contributing to RabbitMQ.

Please add a license header to the new test module and sign our CLA when you have a moment.

@Qian-Cheng-nju
Copy link
Copy Markdown
Contributor Author

Qian-Cheng-nju commented Mar 25, 2026

Thanks! @michaelklishin License header added. I've sent an email to sign the CLA.

@kjnilsson kjnilsson self-requested a review March 25, 2026 08:42
@Qian-Cheng-nju
Copy link
Copy Markdown
Contributor Author

Hi all! I have signed the CLA! Please feel free to contact me if you need anything else.

@kjnilsson
Copy link
Copy Markdown
Contributor

@Qian-Cheng-nju I think the fix looks fine but I would like the test for it to be added to one of the existing test suites, not a new suite of it's own.

Copy link
Copy Markdown
Contributor

@kjnilsson kjnilsson left a comment

Choose a reason for hiding this comment

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

Please add the test to one of the existing test suites

@Qian-Cheng-nju
Copy link
Copy Markdown
Contributor Author

Thanks @kjnilsson! Moved the test into ra_server_SUITE as follower_cluster_change_overwrite.

@kjnilsson kjnilsson merged commit a994474 into rabbitmq:main Mar 26, 2026
7 checks passed
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.

3 participants