rabbitmq / ra

A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Other
798 stars 93 forks source link

Fix crash caused by receiving `#append_entries_reply{success=false}` from unknown peer #432

Closed sile closed 2 months ago

sile commented 2 months ago

Proposed Changes

This PR fixes a ra server process (leader) crash caused by receiving a #append_entries_reply{success=false} message from an unknown peer.

Types of Changes

What types of changes does your code introduce to this project? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask on the mailing list. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further Comments

If the patch in this PR is not applied, the following crash log will be generated by the append_entries_reply_no_success_from_unknown_peer test case.

=== Location: [{ra_server,handle_leader,472},
              {ra_server_SUITE,append_entries_reply_no_success_from_unknown_peer,989},
              {test_server,ts_tc,1794},
              {test_server,run_test_case_eval1,1303},
              {test_server,run_test_case_eval,1235}]
=== === Reason: no match of right hand side value 
                 #{{n1,'ct_ra@localhost'} =>
                       #{status => normal,next_index => 1,match_index => 0,
                         query_index => 0,commit_index_sent => 0}}
  in function  ra_server:handle_leader/2 (src/ra_server.erl, line 472)
  in call from ra_server_SUITE:append_entries_reply_no_success_from_unknown_peer/1 (test/ra_server_SUITE.erl, line 989)
  in call from test_server:ts_tc/3 (test_server.erl, line 1794)
  in call from test_server:run_test_case_eval1/6 (test_server.erl, line 1303)
  in call from test_server:run_test_case_eval/9 (test_server.erl, line 1235)
kjnilsson commented 2 months ago

thank you @sile !

sile commented 2 months ago

👍