Handle delete_and_terminate throws in recovery - #649
Open
the-mikedavis wants to merge 1 commit into
Open
Conversation
`ra_server:recover/1` folded through the log but did not catch the throw for `delete_and_terminate`. This leads to a crash loop on boot if the server appends a deletion command, does not apply it, and then reboots. We can `try`/`catch` and transition to terminating_follower instead.
|
Tick the box to add this pull request to the merge queue (same as
|
Collaborator
Author
Raft log dump (redacted)...Persisted last applied was index 21, right before the deletion command. [{0,0,undefined},
{1,1,{noop,#{ts => 123456789},3}},
{2,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{update_config,
#{name => my_vhostname_my_queuename,
max_length => undefined,max_bytes => undefined,
created => 123456789,
queue_resource => {resource,<<"my_vhostname">>,queue, <<"my_queuename">>},
dead_letter_handler =>
{at_most_once,
{rabbit_quorum_queue,dead_letter_publish,
[{resource,<<"my_vhostname">>,exchange,<<"my_exchangename">>},
<<"yada_yada">>,
{resource,<<"my_vhostname">>,queue,<<"my_queuename">>}]}},
become_leader_handler =>
{rabbit_quorum_queue,become_leader,
[{resource,<<"my_vhostname">>,queue,<<"my_queuename">>}]},
overflow_strategy => drop_head,delivery_limit => undefined,
expires => 190000,msg_ttl => 180000,
single_active_consumer_on => false,
max_in_memory_length => undefined,
max_in_memory_bytes => undefined}},
await_consensus}},
{3,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{4,1,
{'$usr',
#{ts => 123456789},
{enqueue,Pid,1, #mc{...}},
{notify,0,Pid}}},
{5,1,
{'$usr',#{ts => 123456789},{down,Pid,normal},noreply}},
{6,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{7,1,
{'$usr',
#{ts => 123456789},
{enqueue,Pid,1,#mc{...}},
{notify,0,Pid}}},
{8,1,
{'$usr',#{ts => 123456789},{down,Pid,normal},noreply}},
{9,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{10,1,
{'$usr',
#{ts => 123456789},
{enqueue,Pid,1,#mc{...}},
{notify,0,Pid}}},
{11,1,
{'$usr',#{ts => 123456789},{down,Pid,normal},noreply}},
{12,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{13,1,
{'$usr',
#{ts => 123456789},
{enqueue,Pid,1,#mc{...}},
{notify,0,Pid}}},
{14,1,
{'$usr',#{ts => 123456789},{down,Pid,normal},noreply}},
{15,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{16,1,
{'$usr',
#{ts => 123456789},
{enqueue,Pid,1,#mc{...}},
{notify,0,Pid}}},
{17,1,
{'$usr',#{ts => 123456789},{down,Pid,normal},noreply}},
{18,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{19,1,
{'$usr',
#{ts => 123456789},
{enqueue,Pid,1,#mc{...}},
{notify,0,Pid}}},
{20,1,
{'$usr',#{ts => 123456789},{down,Pid,normal},noreply}},
{21,1,{'$usr',#{ts => 123456789},{timeout,expire_msgs},noreply}},
{22,1,
{'$ra_cluster',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
delete,await_consensus}},
{23,1,
{'$usr',
#{ts => 123456789,
from => {Pid, [alias|Reference]}},
{register_enqueuer,Pid},
await_consensus}},
{24,2,{noop,#{ts => 123456789},3}},
{25,2,{'$usr',#{ts => 123456789},{timeout,expire_msgs},noreply}},
{26,2,
{'$usr',
#{ts => 123456789,
from =>
{Pid,
[alias|Reference]}},
{update_config,
#{name => my_vhostname_my_queuename,
max_length => undefined,max_bytes => undefined,
created => 1785155367902,
queue_resource => {resource,<<"my_vhostname">>,queue,<<"my_queuename">>},
dead_letter_handler =>
{at_most_once,
{rabbit_quorum_queue,dead_letter_publish,
[{resource,<<"my_vhostname">>,exchange,<<"my_exchangename">>},
<<"yada_yada">>,
{resource,<<"my_vhostname">>,queue,<<"my_queuename">>}]}},
become_leader_handler =>
{rabbit_quorum_queue,become_leader,
[{resource,<<"my_vhostname">>,queue,<<"my_queuename">>}]},
overflow_strategy => drop_head,delivery_limit => undefined,
expires => 190000,msg_ttl => 180000,
single_active_consumer_on => false,
max_in_memory_length => undefined,
max_in_memory_bytes => undefined}},
await_consensus}},
{27,2,{'$usr',#{ts => 123456789},{timeout,expire_msgs},noreply}}]Log crash snippet... |
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.
ra_server:recover/1folded through the log but did not catch the throw fordelete_and_terminate. This leads to a crash loop on boot if the server appends a deletion command, does not apply it, and then reboots. We cantry/catchand transition to terminating_follower instead.I saw this in a 3.13 cluster recently and saw that it's still possible on the latest main, at least theoretically. I'll post a redacted snippet of the raft log I captured where this occurred.