rabbitmq-server icon indicating copy to clipboard operation
rabbitmq-server copied to clipboard

Move projection registration out of Khepri setup

Open the-mikedavis opened this issue 1 year ago • 2 comments

rabbit_khepri:setup/0 is always called during boot for the sake of clustering. Previously we registered projections during rabbit_khepri:setup/0 meaning that even if you run Rabbit 3.13.x without enabling the khepri_db feature flag you will attempt to register projections. It's a benign bug - it doesn't cause any bad behavior other than a potential timeout on boot if a server is in a minority - but it modifies the Khepri store so we need to consider the projections when we reorganize the tree (#11225).

Instead of registering projections during rabbit_khepri:setup/0 we should register them in two spots:

  • In init (rabbit_db:init/0), a boot step run after rabbit_khepri:setup/0 which has a Khepri-specific branch, and only if we detect that the database is blank. (We could always register on init when Khepri is enabled but there's no need to unless the database is blank.)
  • In the enable callback for the khepri_db feature flag.

In the future when we want to unregister projections, we can add that step before rabbit_khepri:register_projections/0 to the enable callback for the khepri_db feature flag (using https://github.com/rabbitmq/khepri/pull/282).

the-mikedavis avatar Aug 01 '24 20:08 the-mikedavis

In the future when we want to unregister projections, we can add that step before rabbit_khepri:register_projections/0 to the enable callback for the khepri_db feature flag (using rabbitmq/khepri#282).

Do you want to wait for the unregister_projections() API to use it in this pull request? I’m not sure I get all the ins and outs of the upgrade problem.

dumbbell avatar Aug 12 '24 10:08 dumbbell

Yeah let's wait for that since we also want the fence API to await a leader (as mentioned above)

the-mikedavis avatar Aug 12 '24 11:08 the-mikedavis

Khepri 0.15.0 is now released and used in RabbitMQ main branch.

dumbbell avatar Sep 05 '24 13:09 dumbbell

I'll set up the backports once we have the prerequisite PRs backported. In particular this PR needs https://github.com/rabbitmq/rabbitmq-server/pull/11672

the-mikedavis avatar Sep 09 '24 14:09 the-mikedavis