A3 package 2: the store's mode from config, and no append before it joins (mcl-mail#35) #36
Loading…
Reference in a new issue
No description provided.
Delete branch "pluto/2-store-mode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A3 package 2 (martha-ai/mcl-martha#1): mail's store can run in cluster mode, and a cluster-mode node never appends before its store has joined.
Refs macula-services/mcl-mail#35, martha-ai/mcl-martha#1, reckon-db-org/reckon-db#2, #4, #14, macula-services/mcl-om#8
What changes
The mode comes from config.
mcl_mail_store:mode/0reads{mcl_mail, store_mode}:singleunless a release sayscluster, and anything else is anerror({store_mode_not_a_mode, Bad})at boot.mcl_mail_service:event_store/0takesmodefrom it. The shipped config namessingle, which is every box today; a clustered mcl-martha bundle is the one place that overrides it.One append seam. The nine CMD desks called
evoq_command_router:dispatch/2with identical options; they now callmailbox_dispatch:dispatch/1, which in cluster mode answers{error, store_not_joined}whilereckon_db_cluster:local_healthy/1is false. In single mode it is the same call as before, options included (asserted once).The delete-after-read path is checked like any other append. A read appends: a letter is carried twice and each carry is an event.
mark_fetched_letter_readgoes through the seam, and its best-effort rule is kept: a fetch served from an unjoined cluster store still answers, the carry is not recorded, and the refusal is logged.The operator rule is documented. A store that holds events refuses every join, so the node that holds the data starts first while the cluster forms; the README names the recovery step for an empty cluster that formed without it, and the rule that a one-member cluster store never reads as joined.
The pin.
reckon_dbis~> 5.12.0for the build. The land waits for 5.12.1 (reckon-db#14,is_activeunanswered during a leadership transfer): the floor rises to~> 5.12.1before this lands and no service enables cluster mode before it.Nothing here runs twice per partition. Mail publishes and subscribes to no mesh topic, so no side effect of this service is wrapped in
mcl_om_singletonand a netsplit changes nothing in what mail does.What to check
mailbox_dispatchis the only module that callsevoq_command_router:dispatch(in either app's source, held by a test that scans both (with a non-empty guard so it cannot pass on an empty list).{error, store_not_joined}comes back and the mock's call count is zero.local_healthyis reckon-db's own predicate (its guide, "Do not append before the store has joined"); no private copy of the join rule is made here.Verified locally
OTP 28.4.3 / rebar 3.28.0: compile clean,
MCL_LINT=1 rebar3 lintclean,rebar3 eunit171 tests, no failures,rebar3 dialyzerclean (52 files).{mcl_mail, store_mode} is single unless a release says cluster. mode/0 refuses anything else at boot, naming the value it got: a typo that ran a clustered box as a single store would give every node its own history, and one that ran a lone box as a cluster store would stop every append. The shipped config names single, so nothing changes for a box that sets nothing. The nine CMD desks and the delete-after-read mark now dispatch through one seam, mailbox_dispatch, which in cluster mode answers {error, store_not_joined} while reckon_db_cluster:local_healthy/1 is false. The join counts the store and then joins, and an event appended in between is wiped by the join (reckon-db#4). A read is an append too (a letter is carried twice, each carry an event), so its mark is gated as well and stays best effort: the fetch answers, the carry is not recorded, and the refusal is logged. README carries the operator rule the store's own guard implies: start the node that holds the data first, while the cluster forms, or the empty boxes form a cluster of their own and the holder never joins. It also says a one-member cluster store never reads as joined, so a box that runs alone belongs in single. reckon_db moves to ~> 5.12.0 for the build. The floor rises to 5.12.1 before any release enables cluster mode: 5.12.0's is_active can go unanswered during a leadership transfer (reckon-db#14). Verified on OTP 28.4.3: compile clean, MCL_LINT=1 rebar3 lint clean, rebar3 eunit 171 tests, rebar3 dialyzer clean.Mercurius's required item 1. The scan in the previous commit proves no other module calls the router; it cannot see a desk that reaches it by another route. This runs every one of the nine desks' own dispatch/1 with a real command and counts the mocked router: on an unjoined cluster store each answers {error, store_not_joined} with zero calls, and on a single store each calls it exactly once.