Wiki Concepts
Durability and acknowledgements
Exactly what a Mirexa acknowledgement promises — the write-ahead log fsync and group commit, the shed-and-retry guarantee, ambiguous failures and how to reconcile them, and the limits on one node and in a cluster.
A storage system's acknowledgement is a promise, and a promise is only useful if you know its exact terms. This page states what each kind of Mirexa acknowledgement guarantees, what an error guarantees, which failures leave a write's outcome unknown, and what you should do in each case — on one node and in a cluster.
The two durability modes
Every write call takes a durability mode:
| Mode | The call returns when | It promises |
|---|---|---|
Acked (DurabilityAcked, the zero value; -, on by default, in the CLI) |
the node's INGEST_ arrives |
the batch is in the write-ahead log and the log has been fsynced |
Fire-and-forget (DurabilityFireAndForget; -) |
the bytes are written to the socket | nothing |
Acked is the zero value deliberately: the safe meaning is the one you get by not choosing.
What "acked" means, exactly
The acknowledgement is a durability receipt, not a receipt of delivery. The node appends the batch's record to its write-ahead log and applies the batch to the stream's hot cache, then waits until a flush has written and fsynced that record, and only then acknowledges — so an acknowledged batch is both durable and visible to reads.[1] A power cut immediately after the acknowledgement loses nothing: on restart the node replays the log and the batch is there.[2]
The fsync is group-committed: any number of batches waiting on the log are satisfied by one flush and one fsync, so the cost of acknowledged ingest is roughly one fsync per group of concurrent batches, not one per batch.[3]
That is the promise under the default wal.sync_policy: always. The policy can be relaxed:
wal. |
An acknowledgement means |
|---|---|
always (default) |
the record is fsynced to stable storage |
interval |
the record has been written to the operating system; it is fsynced within wal. (default 1 s). A machine crash can lose up to that much acknowledged data. |
disabled |
the record has been written to the operating system; durability is the OS's. |
The acknowledgement can never promise more than the policy the operator configured.[4]
A batch flushed later from the hot cache to a chunk, or drained at a clean shutdown, stays durable throughout: the log is reclaimed only past records whose bars are installed in chunks.
What fire-and-forget means, exactly
There is no response frame, so a batch the node refuses — invalid values, timestamps it cannot place, a derived stream — is dropped and you are never told, and nothing is retried. Use it when throughput matters more than per-batch certainty, and send a periodic acked batch as a barrier: frames on one connection are processed in order, so an ack proves every earlier batch on that connection was handled — though not that each was accepted.
Two exceptions are stronger than their mode: a restatement of a flushed bar is made durable even fire-and-forget (a patch is written whole or not at all), and acked history means the chunks are installed, not just logged — a stronger promise than a live ack. Fire-and-forget history is staged and not yet queryable until an acked history call for the stream.
Overloaded: the one retryable refusal
When a node cannot absorb a batch — the write-ahead log buffer is full, or the stream's hot
cache is full and the flush that would make room has not come in time — it answers
Overloaded with a backoff hint. That code is a promise that nothing from the batch
was stored: it is raised before the record reaches the log.[5] So re-sending the whole
batch is a first attempt, not a retry of something half-done, and it cannot create a
duplicate.
The Go and Python SDKs re-send shed acked writes and reads automatically (Go default: up to
1,000 attempts, honouring the hint but capping each wait at 250 ms, bounded by your
context). A call shed on every attempt fails with ErrRetriesExhausted.[6] No
other error code is retried: every other refusal is a statement about the request, and
re-sending it fails the same way. RemoteError.RetryAfter() is the one place that decides,
and it says yes only to Overloaded.
A node also sheds briefly while a partition is frozen for a move between nodes, or while a newly promoted primary is replaying its log. The same retry rides through both.
Ambiguous failures
If the connection dies while a write is in flight, the batch may have been applied with
only the acknowledgement lost. The SDK cannot know, so it returns ErrAmbiguous and
does not retry.[7]
The distinction that matters:
| When the connection failed | Outcome |
|---|---|
| Before the request was sent — including a connection the node had already closed while it was idle | Not ambiguous. The SDK sends the batch on a fresh connection, as a first attempt. |
| While the request was in flight | Ambiguous for writes. Reads are simply re-run. |
Reconciling an ambiguous write
- Candles: re-send the same batch with an ordinary write. Bars that were stored are found unchanged and skipped; bars that were not are written. (A re-send does overwrite any bar someone else restated in the meantime with your older values; that is why the SDK does not do it for you.)[8]
- A stream's first batch: if the lost batch was the stream's first, its bars are now
older than everything the stream has since stored, and the re-send is refused with
HistoryRequired. Send them through the history route. - History: read the range back; re-send only what is missing (a re-sent installed range is refused).
- Ticks: a trade has no key, so a re-sent tick batch can store trades twice. Read the range back and send only what is missing.
mirexa-cli load reconciles this way automatically: it reads the batch's window back and sends
only what is absent.
Batching moves the receipt
With a batcher (NewCandleBatcher, NewTickBatcher, or mirexa-cli ingest), Add
returning nil means the record is buffered, not stored. The receipt arrives later — at
a later Add, at Flush, or at Close — and a failed flush poisons the batcher so
every later call returns the error rather than mixing stored and unstored data. A program
that exits without Close loses what was buffered, and was never acknowledged for it.
Graceful versus crash
| Event | Single node | Cluster |
|---|---|---|
| Clean shutdown (SIGTERM) | Nothing acknowledged is lost; the hot cache is drained to chunks.[9] | Nothing acknowledged is lost: the node sheds new writes, finishes in-flight ones, and lets its copies pull what it made durable before stopping.[10] |
| Graceful partition move | — | Nothing acknowledged is lost.[11] |
Process crash, kill -, power cut |
Nothing acknowledged is lost; the log is replayed. | The node itself loses nothing, but if its partitions fail over, the new primary may lack writes the old one acknowledged after the copy's last replication pull. |
| Disk loss | Everything on that disk. | Recovered from copies, minus the crash window above. |
The cluster's crash window
In a cluster, an acknowledgement is the primary's alone: copies pull from the primary asynchronously, and the ack does not wait for them. A primary that crashes can therefore lose writes it acknowledged during roughly its copies' last poll. Measured in the shipped binary on one laptop (2026-10-20, seven runs at two loads): 0–110 acknowledged candles lost at about 600–2,300 candles/s, 0–3,000 at about 100K/s, every one acknowledged within 2–40 ms before the kill. What is bounded and tested is that nothing older than the in-sync staleness bound is lost, and that the surviving copy holds a prefix of each stream.[12] If you need a write to survive the loss of its primary, there is no stronger acknowledgement to ask for at this commit; reconcile after a failover by reading back.
Other limits
- One disk. On a single node, the acknowledgement covers a process crash and a power cut on that machine, not the failure of its disk.
- No node-wide memory budget. Each log writer's buffer is bounded
(
wal.max_buffer_bytes), but there is no cap across all streams.
References
Source
wal.Writer.AwaitDurable— the group-commit barrier.config.WALConfig—sync_policy,sync_interval,max_buffer_bytes,buffer_wait_timeout.ingestion.ErrOverloaded,OverloadErrorServer.writeShedRemoteError.RetryAfter;RetryOptions- /docs/sdk-durability.md — the SDK's own statement of the same promises.
Tests
TestServer_AckedCandleIngestIsInWALBeforeAckin /tests/ack_durability_test.goTestCrash_KillDashNine,TestCrash_TicksSurviveKillDashNinein /tests/recovery_test.goTestWriter_PoisonedAfterPermanentFlushFailurein /internal/wal/writer_test.goTestIngest_RetriedShedBatchesLandExactlyOncein /internal/network/ingest_retry_test.goTestIngest_AFullHotCacheWaitsForTheFlushInsteadOfRefusingin /internal/ingestion/admission_wait_test.goTestResilient_InFlightWriteIsAmbiguousNotRetried,TestResilient_AWriteAfterTheServerClosedAnIdleConnectionIsSentFreshin /internal/wireclient/resilient_test.goTestChaos_NoAckedRecordIsLost,TestChaos_AmbiguousBatchIsReconciledPromptlyin /tests/chaos_reconnect_test.goTestShutdownDrain_PersistsEverythingToChunksin /tests/shutdown_drain_test.goTestServerBinary_ASigtermedPrimaryUnderLoadLosesNoAckedWritein /tests/server_binary_sigterm_test.goTestCutover_UnderConcurrentWritesNoAckedWriteIsLostin /cmd/server/cutover_test.goTestServerBinary_ACrashedPrimaryLosesOnlyWritesItsCopyHadNotPulledin /tests/server_binary_crash_loss_test.go
Further reading
External
- Pat Helland, "Life beyond Distributed Transactions: an Apostate's Opinion", CIDR 2007 — on idempotence as the basis for safe retries. https://www.cidrdb.org/cidr2007/papers/cidr07p15.pdf
- Apache Kafka documentation, "Replication" (acks and in-sync replicas) — https://kafka.apache.org/documentation/#replication
TestServer_AckedCandleIngestIsInWALBeforeAck. ↩︎TestCrash_KillDashNine,TestCrash_TicksSurviveKillDashNine. ↩︎AwaitDurable's contract andWALConfig.SyncPolicyin /internal/config/config.go. ↩︎ingestion.ErrOverloaded,Server.writeShed;TestIngest_RetriedShedBatchesLandExactlyOnce,TestIngest_AFullHotCacheWaitsForTheFlushInsteadOfRefusing. ↩︎TestResilient_InFlightWriteIsAmbiguousNotRetried,TestResilient_AWriteAfterTheServerClosedAnIdleConnectionIsSentFresh. ↩︎TestChaos_AmbiguousBatchIsReconciledPromptly,TestChaos_NoAckedRecordIsLost. ↩︎TestShutdownDrain_PersistsEverythingToChunks. ↩︎TestServerBinary_ASigtermedPrimaryUnderLoadLosesNoAckedWrite. ↩︎TestCutover_UnderConcurrentWritesNoAckedWriteIsLost. ↩︎TestServerBinary_ACrashedPrimaryLosesOnlyWritesItsCopyHadNotPulled; the figures are those recorded with it in the repository's notes. ↩︎