Skip to content

Track projectors state (replaying/activating/active) in the database#472

Merged
erikrozendaal merged 15 commits intomasterfrom
track-projectors
Jun 20, 2025
Merged

Track projectors state (replaying/activating/active) in the database#472
erikrozendaal merged 15 commits intomasterfrom
track-projectors

Conversation

@erikrozendaal
Copy link
Copy Markdown
Member

@erikrozendaal erikrozendaal commented Jun 10, 2025

The event publisher and projector check the current state when processing events to:

  • avoid publishing any events if there is an unknown projector active (to avoid running old code on upgraded systems)
  • prevent processing events for a projector where a newer version, so there is no need to shut down the old code before starting up the new code. A load balancer should redirect requests the new code as soon as possible after activating the newer projector since the old code will start failing with NewerProjectorIsActiveError errors.

This PR is another step towards allowing rolling upgrades, where version N and version N+1 code is running concurrently during an upgrade, without affecting any users.

TODO

  • document need for activate_current_configuration!
  • changelog

process_events
end

def replay_events(events)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be in an EventReplayer or so?

During activation the last existing events are replayed before the
projector is marked active. Block new events since they will not be
picked up by the replay process.
Use `EventStore#replay_events_from_cursor` instead.
As long as the projector_states table is empty it is assumed the
current Sequent configuration is correct. This allows easier unit
testing (since there is no need to activate a configuration every time
it changes in the test) and allows for backwards compatibility with
the current deployment process (using online and offline migration).
@erikrozendaal erikrozendaal merged commit 724fc79 into master Jun 20, 2025
5 checks passed
@erikrozendaal erikrozendaal deleted the track-projectors branch June 20, 2025 11:29
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.

2 participants