A3 packages 2 and 4: the store mode comes from config, a cluster node waits for its join, and the mesh emitters run once per cluster #7

Manually merged
terra merged 4 commits from venus/a3-mesh-singleton into main 2026-12-02 13:06:00 +00:00
Member

Purpose (capability): whiteboard can run on a clustered store, so every node of a cluster holds every board and a node can go down without losing one.

A3 package 2 (#6) together with the held A3 package 4 (#5) in one range: 509c6c5..a3b0a47.

What changes

  • MCL_STORE_MODE = single (default, unchanged) or cluster. Any other value refuses the boot by name. GuideBoardLifecycle.Store.mode/0 is the one reader.
  • Cluster mode: no append before the join. EventStore.open/1 asks reckon-db to join once (reckon-db#15: a store started after its node connected never joins by itself). It returns only when reckon_db_cluster:local_healthy/1 holds. The service, its mesh write relays and the web UI start after open, so nothing appends in reckon-db's count-then-join window.
  • Emitters by mode. In cluster mode the three *ToMesh emitters run under mcl_om_singleton, one per cluster (#5). In single mode each node runs its own, because each store holds only that node's events.
  • reckon_db ~> 5.12 (reckon-db#2).

Operator rules (README, "Cluster mode")

  • A data holder refuses every join, including a join to an existing multi-member cluster, and it stays refused. Start the node that holds data first. If the empty nodes clustered first, the README gives the operator step from reckon-db's guide.
  • A lone cluster-mode node waits for a peer and serves nothing until it joins. Two nodes give copies only; three are needed for failover.

Netsplit: one singleton per connected part

global runs one copy of each emitter in every connected partition, so during a split each side's emitter publishes its own side's events, and the receivers are idempotent. On healing, global stops one copy and the survivor takes over. That causes a burst, not a gap: evoq backfills a handler that registers late from 0, events from before the node's boot are skipped as replay, and the rest are republished (#5 comment 8131). No duplicate changes a receiver's state. I see no harm that needs a guard, and none is added.

Tests (local: format, compile --warnings-as-errors, credo, mix test 132/0, dialyzer)

  • cluster_open_test.exs: two real peers in cluster mode, connected before the second store starts. The lone node does not open in 10 s; both open once they meet. Mutants: no wait → the lone node opens (fails); no join ask → the second never opens (fails).
  • one_node_publishes_test.exs: single mode gives one handler per node on two connected peers and a plain child in this VM; cluster mode gives one per cluster, moving on takeover. Mutants: mode fixed to cluster fails 2, fixed to single fails 1.
  • runtime_store_mode_test.exs: the real runtime.exs: unset is single; single and cluster are read; any other value is refused by name.

Before the land

reckon-db#14 (a new leader cannot answer is_active during activation): the pin floor moves to reckon_db 5.12.1 once it is on hex. No service moves to cluster mode before then.

Refs #6, Refs #5

Purpose (capability): whiteboard can run on a clustered store, so every node of a cluster holds every board and a node can go down without losing one. A3 package 2 (#6) together with the held A3 package 4 (#5) in one range: 509c6c5..a3b0a47. ## What changes - `MCL_STORE_MODE` = `single` (default, unchanged) or `cluster`. Any other value refuses the boot by name. `GuideBoardLifecycle.Store.mode/0` is the one reader. - **Cluster mode: no append before the join.** `EventStore.open/1` asks reckon-db to join once (reckon-db#15: a store started after its node connected never joins by itself). It returns only when `reckon_db_cluster:local_healthy/1` holds. The service, its mesh write relays and the web UI start after open, so nothing appends in reckon-db's count-then-join window. - **Emitters by mode.** In cluster mode the three *ToMesh emitters run under `mcl_om_singleton`, one per cluster (#5). In single mode each node runs its own, because each store holds only that node's events. - reckon_db `~> 5.12` (reckon-db#2). ## Operator rules (README, "Cluster mode") - **A data holder refuses every join**, including a join to an existing multi-member cluster, and it stays refused. Start the node that holds data first. If the empty nodes clustered first, the README gives the operator step from reckon-db's guide. - **A lone cluster-mode node waits** for a peer and serves nothing until it joins. Two nodes give copies only; three are needed for failover. ## Netsplit: one singleton per connected part `global` runs one copy of each emitter in every connected partition, so during a split each side's emitter publishes its own side's events, and the receivers are idempotent. On healing, `global` stops one copy and the survivor takes over. That causes a burst, not a gap: evoq backfills a handler that registers late from 0, events from before the node's boot are skipped as replay, and the rest are republished (#5 comment 8131). No duplicate changes a receiver's state. I see no harm that needs a guard, and none is added. ## Tests (local: format, compile --warnings-as-errors, credo, mix test 132/0, dialyzer) - `cluster_open_test.exs`: two real peers in cluster mode, connected before the second store starts. The lone node does not open in 10 s; both open once they meet. Mutants: no wait → the lone node opens (fails); no join ask → the second never opens (fails). - `one_node_publishes_test.exs`: single mode gives one handler per node on two connected peers and a plain child in this VM; cluster mode gives one per cluster, moving on takeover. Mutants: mode fixed to cluster fails 2, fixed to single fails 1. - `runtime_store_mode_test.exs`: the real runtime.exs: unset is single; single and cluster are read; any other value is refused by name. ## Before the land reckon-db#14 (a new leader cannot answer `is_active` during activation): the pin floor moves to reckon_db 5.12.1 once it is on hex. No service moves to cluster mode before then. Refs #6, Refs #5
The three *ToMesh handlers start through mcl_om_singleton (mcl_om ~> 1.9),
so a replicated store's events go to the mesh once per cluster, not once
per node. A two-node peer test pins one handler per event type and the
takeover; plain handlers fail it.

Not to be pushed alone: it is right only once the store replicates
(A3 package 2, store mode from config). With mode single, the one holder
would publish only its own node's events.
A3 package 2: the store mode comes from config, and a cluster node waits for its join (mcl-whiteboard#6)
All checks were successful
c4 model / c4-drift (pull_request) Successful in 2s
c4 model / c4-model-1 (pull_request) Successful in 4s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 7m3s
a3b0a47371
MCL_STORE_MODE picks single (the default, unchanged) or cluster; any other
value refuses the boot by name. GuideBoardLifecycle.Store.mode/0 is the one
reader, for both the store and the emitters.

In cluster mode, MclWhiteboard.EventStore.open/1 asks reckon-db to join once
(reckon-db#15: a store started after its node connected never joins by
itself). It returns only when reckon_db_cluster:local_healthy/1 holds, so
nothing appends in reckon-db's count-then-join window, where a join would
wipe it. A lone cluster-mode node waits for a peer.

The *ToMesh emitters run under mcl_om_singleton only in cluster mode. In
single mode each node's store holds only its own events, so each node runs
its own.

reckon_db ~> 5.12 (reckon-db#2: a store that holds events never joins). The
README states the operator rules: start the node that holds data first, and
a lone node waits.
Floor round: reckon_db ~> 5.12.1, and open/1 no longer asks for the join (mcl-whiteboard#6)
All checks were successful
c4 model / c4-drift (pull_request) Successful in 2s
c4 model / c4-model-1 (pull_request) Successful in 2s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 8m21s
d9b3b59963
reckon_db 5.12.1 carries reckon-db#14 (a new leader answers is_active during
activation) and reckon-db#15 (a store started after its node connected joins
by itself). So the one-time join_cluster/1 ask in open/1 is gone. The
connected-before-start case in cluster_open_test stays green without it.
Floor round: evoq ~> 1.32 across the umbrella (mcl-whiteboard#6)
All checks were successful
c4 model / c4-drift (pull_request) Successful in 4s
c4 model / c4-model-1 (pull_request) Successful in 7s
c4 model / c4-model (pull_request) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (pull_request) Successful in 7m35s
c4 model / c4-drift (push) Successful in 5s
c4 model / c4-model-1 (push) Successful in 5s
c4 model / c4-model (push) Successful in 0s
ci / gates (OTP 28.4.3 / Elixir 1.18.4) (push) Successful in 8m7s
9c6fe7cb1a
evoq 1.32.0 routes one aggregate id's commands to one node of a cluster
(evoq#8), which cluster mode needs. One floor in all three apps that name evoq.
terra manually merged commit 9c6fe7cb1a into main 2026-12-02 13:06:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
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-whiteboard!7
No description provided.