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
813 stars 96 forks source link

Fix snapshot installation CRC failure #369

Closed kjnilsson closed 1 year ago

kjnilsson commented 1 year ago

Due to the unwise use of term_to_binary rather than using the original binary data in the replication of snapshot states.

This change:

Introduces a new optional ra_snapshot callback: context/0

This is called by the sending Ra leader node to discover context and capabilities of the receiver. In this case it is used to indicate if the receiver is capabable of receiving the entire snapshot file.

Receiving the entire file is the updated approach that ensures the CRC check will be done on the same binary data it was generated from.

If the receiver does not have the context/0 callback or does not indicate support the old approach of sending the deserialised metat data map and any data following that is used.

When a snapshot is received from an old node (i.e. not including the entire file) the receiver will not validate the checksum (as it may fail due to differences in map serialisation) and instead patch up it's local file with it's own calculcated checksum.

The scenario where a snapshot taken by a newer version of OTP and is then sent to a member using the old code cannot be handled and the old node will fail at snapshot checksum validation.

Fixes #368

michaelklishin commented 1 year ago

https://github.com/rabbitmq/rabbitmq-server/pull/8143 makes rolling upgrades to Erlang 26 succeed under a constant load involving QQs.