Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rabbit_db: Copy feature states early when joining a cluster #9682

Merged
merged 6 commits into from
Oct 17, 2023

Conversation

dumbbell
Copy link
Member

Why

So far, the feature states were copied from the cluster after the actual join. However, the join may have reloaded the feature flags registry, using the previous on-disk record, defeating the purpose of copying the cluster's states.

This was done in this order to have a simpler error handling.

How

This time, we copy the remote cluster's feature states just after the reset.

If the join fails, we reset the feature flags again, including the on-disk states.

@dumbbell dumbbell added this to the 3.13.0 milestone Oct 11, 2023
@dumbbell dumbbell self-assigned this Oct 11, 2023
@dumbbell dumbbell force-pushed the fix-feature-flags-reset-during-join_cluster branch 9 times, most recently from 8ebc018 to a010a79 Compare October 16, 2023 14:55
This is probably the result of a copy-paste.
[Why]
When a Khepri-based node joins a Mnesia-based cluster, it is reset and
switches back from Khepri to Mnesia. If there are Mnesia files left in
its data directory, Mnesia will restart with stale/incorrect data and
the operation will fail.

After a migration to Khepri, we need to make sure there is no stale
Mnesia files.

[How]
We use `rabbit_mnesia` to query the Mnesia files and delete them.
[Why]
This relies on Mnesia and is only useful when using Mnesia. Indeed,
there is no partition handling when Khepri is used.
[Why]
`reset_registry/0` reset the in-memory states so far, but left the
on-disk record. This is inconsistent.

[How]
After resetting the in-memory states, we remove the file on disk.
…disk

[Why]
Sometimes, we need to reset the in-memory registry only, like when we
restart the `rabbit` application, not the whole Erlang node. However,
sometimes, we also need to delete the feature states on disk. This is
the case when a node joins a cluster.

[How]
We expose a new `reset/0` function which covers both the in-memory and
on-disk states.

This will be used in a follow-up commit to correctly reset the feature
flags states in `rabbit_db_cluster:join/2`.
[Why]
So far, the feature states were copied from the cluster after the actual
join. However, the join may have reloaded the feature flags registry,
using the previous on-disk record, defeating the purpose of copying the
cluster's states.

This was done in this order to have a simpler error handling.

[How]
This time, we copy the remote cluster's feature states just after the
reset.

If the join fails, we reset the feature flags again, including the
on-disk states.
@dumbbell dumbbell force-pushed the fix-feature-flags-reset-during-join_cluster branch from a010a79 to f95ccaf Compare October 17, 2023 07:38
@dumbbell dumbbell marked this pull request as ready for review October 17, 2023 10:58
@dumbbell dumbbell merged commit 549a87c into main Oct 17, 2023
16 checks passed
@dumbbell dumbbell deleted the fix-feature-flags-reset-during-join_cluster branch October 17, 2023 10:58
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.

None yet

1 participant