Skip to content

feat(mongoreactive): add journal event persistence - #955

Open
bercianor wants to merge 3 commits into
masterfrom
feat/mongodb-reactive-journal-events
Open

feat(mongoreactive): add journal event persistence#955
bercianor wants to merge 3 commits into
masterfrom
feat/mongodb-reactive-journal-events

Conversation

@bercianor

Copy link
Copy Markdown
Contributor

No description provided.

@davidfrigolet davidfrigolet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few points from reviewing against the merged sync sibling (flamingock-mongodb-sync-auditstore). None block, but 1 and 2 are easy removals.

Comment thread .gitignore
*.db-wal
*.db-shm
# Local Pi runtime state
.atl/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stray, unrelated to journal events. Not present in #948/#949 or the sync PR. Please drop this line from this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one is intentional. It ignores a directory generated by my local development environment that should never be tracked.

I agree it is unrelated to journal events, but I do not think it warrants a separate PR for a single repository-hygiene entry. It does not affect the implementation or runtime behavior.

persistence = new MongoDBReactiveAuditPersistence(
public AuditPersistenceFactory<CommunityAuditPersistence> getPersistenceFactory() {
return stageId -> {
auditRepository.initialize(autoCreate);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

auditRepository.initialize(autoCreate) (and journalEventStore.initialize below) run here, then again in stagePersistence.initialize(runnerId) -> doInitialize(). Both are guarded so it's harmless, but the sync sibling only initializes inside persistence.doInitialize(). Consolidate to one site. Keep the journal-store init before forStream(stageId) though — the manual-schema validation test depends on that ordering.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I looked into this properly. We cannot just move these calls into doInitialize() with the current flow: forStream(stageId) immediately reads the last persisted journal event, but doInitialize() runs afterwards. That would make the sequencer read the journal before its schema is
created or validated, especially breaking the intended autoCreate=false validation boundary.

The duplicate calls are idempotent and currently preserve the required order:

audit initialization → journal initialization/validation → sequencer creation

I agree the lifecycle is not clean. The right solution is a cross-audit-store refactor: persistence should receive the stage ID and sequencer factory, initialize the repositories, and then create the sequencer itself.

That refactor should be applied consistently across the audit stores, not only MongoDB Reactive. It is therefore better handled separately from this PR, rather than introducing a broader lifecycle-contract change here.

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