A3 package 2: the store's mode from config, one filer per cluster (#19) #20

Closed
vesta wants to merge 0 commits from vesta/cluster-store into main
Member

Refs macula-services/mcl-scribe#19

A3 package 2 for the scribe: the reckon-db store's mode comes from configuration, and the lesson filer's place follows the log.

  • The mode from config. lesson_log:store_mode/0 reads {mcl_scribe, [{store_mode, single | cluster}]}, single by default, and refuses an unknown value by name — a typo must not put a replicated deployment on per-node stores. mcl_scribe_service:event_store/0 and guide_lessons_sup both take their decision from it, so the store and its filer cannot drift. Standalone and every existing deployment are untouched.
  • Never append before the store has joined. In cluster mode mcl_scribe_store:open/1 does not return until reckon_db_cluster:local_healthy/1 says the store is a joined cluster (a live leader, more than one member, the local Raft server answering), so the app does not boot, the mesh does not advertise record_lesson, and nothing is appended into the join window a join would wipe. The wait is not silent: it logs scribe_store_not_joined with what it waits for every few seconds, and it stays there for the operator rather than failing into a restart loop that hides the cause — a data holder is refused a join forever (reckon-db's guide).
  • Operator step, in the README beside store_mode. The node whose store holds the data must be started before the empty nodes join; if the empty nodes form a cluster first, the holder can never join it (recovery steps included).

What a double filer run does on each side of a netsplit. global sees only the nodes it is connected to, so a split runs one filer per connected partition. That double run is safe and no guard is added for it (a new check needs the owner's yes; nothing here names a harm): only the partition holding the log's Raft quorum accepts appends, so normally one side files; and where both sides hold the same queued lesson, filing is at least once and final exactly once — the filer reads the lesson's stream and skips a lesson no longer queued, the aggregate refuses a second final state, and mcl-rag keys a chunk by source and text, so the copy lands on the same chunk.

Tests. lesson_log_tests pins the mode default, the configured value and the refusal by name; mcl_scribe_service_tests pins the store's mode from the service; mcl_scribe_store_tests proves a cluster-mode store holds the boot (the opener has not returned) and that it says what it waits for; guide_lessons_sup_tests pins the plain child in single mode and the mcl_om_singleton guard in cluster mode, and that alone on a node the guard runs the filer.

Gates on this tip (OTP 28, reckon_db 5.12.0): lint, xref, eunit (88 tests), dialyzer — all green.

Not landable yet: the reckon_db pin floor moves to ~> 5.12.1 before the land (reckon-db#14 is open on 5.12.0; no service moves to cluster mode before 5.12.1 is on hex). This tip is for review.

Refs macula-services/mcl-scribe#19 A3 package 2 for the scribe: the reckon-db store's mode comes from configuration, and the lesson filer's place follows the log. - **The mode from config.** `lesson_log:store_mode/0` reads `{mcl_scribe, [{store_mode, single | cluster}]}`, `single` by default, and refuses an unknown value by name — a typo must not put a replicated deployment on per-node stores. `mcl_scribe_service:event_store/0` and `guide_lessons_sup` both take their decision from it, so the store and its filer cannot drift. Standalone and every existing deployment are untouched. - **Never append before the store has joined.** In cluster mode `mcl_scribe_store:open/1` does not return until `reckon_db_cluster:local_healthy/1` says the store is a joined cluster (a live leader, more than one member, the local Raft server answering), so the app does not boot, the mesh does not advertise `record_lesson`, and nothing is appended into the join window a join would wipe. The wait is not silent: it logs `scribe_store_not_joined` with what it waits for every few seconds, and it stays there for the operator rather than failing into a restart loop that hides the cause — a data holder is refused a join forever (reckon-db's guide). - **Operator step, in the README beside `store_mode`.** The node whose store holds the data must be started before the empty nodes join; if the empty nodes form a cluster first, the holder can never join it (recovery steps included). **What a double filer run does on each side of a netsplit.** `global` sees only the nodes it is connected to, so a split runs one filer per connected partition. That double run is safe and no guard is added for it (a new check needs the owner's yes; nothing here names a harm): only the partition holding the log's Raft quorum accepts appends, so normally one side files; and where both sides hold the same queued lesson, filing is at least once and final exactly once — the filer reads the lesson's stream and skips a lesson no longer queued, the aggregate refuses a second final state, and mcl-rag keys a chunk by source and text, so the copy lands on the same chunk. **Tests.** `lesson_log_tests` pins the mode default, the configured value and the refusal by name; `mcl_scribe_service_tests` pins the store's mode from the service; `mcl_scribe_store_tests` proves a cluster-mode store holds the boot (the opener has not returned) and that it says what it waits for; `guide_lessons_sup_tests` pins the plain child in single mode and the `mcl_om_singleton` guard in cluster mode, and that alone on a node the guard runs the filer. Gates on this tip (OTP 28, reckon_db 5.12.0): `lint`, `xref`, `eunit` (88 tests), `dialyzer` — all green. **Not landable yet:** the `reckon_db` pin floor moves to `~> 5.12.1` before the land (reckon-db#14 is open on 5.12.0; no service moves to cluster mode before 5.12.1 is on hex). This tip is for review.
A3 package 2: the store's mode from config, one filer per cluster (#19)
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 4m11s
a284e3554f
The scribe log's reckon-db mode is no longer hardcoded single. It comes from
the service's app env through lesson_log:store_mode/0, single by default, and
an unknown value fails the boot naming it instead of silently falling back to
single. One source of truth: the store's mode and the filer's child shape are
chosen by the same function.

In cluster mode the boot does not finish until the store has joined a cluster
(reckon_db_cluster:local_healthy/1): an event appended to an empty joining node
in the join window is wiped by the join, so no lesson is appended until then.
The wait is not silent: it logs what it is waiting for every few seconds, and
it stays there for the operator rather than failing into a restart loop that
hides the cause (a data holder is refused a join forever).

The filer goes behind mcl_om_singleton when the log is shared, one filer per
connected partition; in single mode it stays the plain per-node worker, as
mcl-scribe#16 settled. A netsplit's double run is safe and needs no guard: only
the quorum side accepts appends, and filing is at least once and final exactly
once.

reckon_db moves to ~> 5.12 (5.12.0): the first release that never wipes a store
that holds events on a join (reckon-db#2).
reckon_db floor moves to ~> 5.12.1 (mcl-scribe#19)
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 5m4s
build-and-push / guard-1 (push) Successful in 2s
build-and-push / guard (push) Successful in 0s
c4 model / c4-model-1 (push) Successful in 11s
c4 model / c4-model (push) Successful in 0s
build-and-push / check (push) Successful in 5m11s
build-and-push / test (push) Successful in 0s
build-and-push / Release (forge, v* tag) (push) Has been skipped
lint-and-test / check (push) Successful in 4m29s
a69a2d7c93
5.12.1 is the release whose leadership-transfer case is deterministic
(reckon-db#14), and no service moves to cluster mode before it. Diff only: the
pin in rebar.config. Gates on it: lint, xref, eunit 88, dialyzer.
Member

Landed by fast-forward: main is a69a2d7c93 (from d9551a35). This repository does not allow the manually-merged style, so the PR is closed by hand.

Landed by fast-forward: main is a69a2d7c935d02ef7ad2a6409f8a406295c426d5 (from d9551a35). This repository does not allow the manually-merged style, so the PR is closed by hand.
terra closed this pull request 2026-12-02 12:30:39 +00:00
All checks were successful
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
lint-and-test / check (pull_request) Successful in 5m4s
build-and-push / guard-1 (push) Successful in 2s
build-and-push / guard (push) Successful in 0s
c4 model / c4-model-1 (push) Successful in 11s
c4 model / c4-model (push) Successful in 0s
build-and-push / check (push) Successful in 5m11s
build-and-push / test (push) Successful in 0s
build-and-push / Release (forge, v* tag) (push) Has been skipped
lint-and-test / check (push) Successful in 4m29s

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
macula-services/mcl-scribe!20
No description provided.