Eventually Consistent: How Do We Know the Systems Eventually Agree?
Eventually consistent event-driven order systems need a reconciliation job that starts from the authoritative order store, not from received messages, so orders whose events were lost (like a fraud-hold release that never reached SAP) still surface. Define "eventually" as a concrete deadline with documented exceptions, query overdue orders cheaply via a PostgreSQL partial index on the waiting status, confirm state with the owning service before repairing, and repair through normal paths reusing the original idempotency key or via compensating actions. Track open cases persistently, process them in small batches, and measure overdue counts, oldest-unresolved age and whether the job actually ran rather than relying on CPU or queue metrics.
Related posts
- The Write Last, Read First Rule
TigerBeetle mediumAdeptWhen an application spans two stores without a shared transaction boundary, such as Postgres for account master data and TigerBeetle for the ledger, one must be designated the system of record and the other the system of reference. Writes go to the system of reference first and the system of record last, and existence checks read the system of record first. This keeps the system traceable: no funded ledger account ever lacks an owner record, even if it is temporarily inconsistent. The approach is implemented with Resonate's durable execution (Distributed Async Await) and idempotent per-store create functions. A result matrix classifies outcomes as success, recovery, conflict or ordering violation, and the application panics to alert an operator on violations.
- Building Workflows, Part 2 – the executor and evaluation
incident.io mediumAdeptincident.io's workflow executor listens for trigger events, evaluates workflow conditions against a scope, and creates a workflow run before executing steps. A broad 'incident-updated' trigger fixes ordering problems with multi-condition workflows. A 'once-for' column backed by a Postgres unique index provides cheap, consistent idempotency, so trigger consumers can be retried safely. To cope with Google Pub/Sub's at-least-once delivery, execution proceeds one step at a time under a SELECT FOR UPDATE row lock, with a JSON progress column recording completed steps. Runs therefore behave serially, resume after crashes without repeating steps, and double as a customer-facing audit log.
- Incident Review: Pageserver outage in us-east-1
Neon mediumAdept
A sudden EC2 instance failure took down a Neon pageserver in us-east-1, leaving about 0.4% of projects unable to read uncached pages for 30 minutes to 2 hours. No data was lost because S3 holds durable storage and secondary locations were pre-warmed. Recovery was slow for three reasons: alerting had a human in the loop and took about 30 minutes, a semi-manual script took about 40 minutes to migrate 17,037 projects, and roughly 20 projects with in-flight operations needed manual fixes. The fix is moving all projects to the Storage Controller, a reconciliation-loop scheduler with its own heartbeats that treats every pageserver call as fallible and fails work over in seconds without human intervention.
- Partition Finalization in Pinterest’s Next-Generation DB Ingestion Framework
Pinterest Engineering hardMasterPinterest's streaming CDC ingestion (Kafka, Flink, Iceberg, Spark) lost the implicit "partition complete" signal that batch loads provided, so it now derives a partition finalization watermark from event time. Each Flink checkpoint records min/max event time and a mergeable t-digest percentile sketch (a few hundred bytes) in the Iceberg snapshot summary. A post-commit hook then computes a monotonic, non-regressing watermark, by default the minimum of per-commit minimums over the last X commits rounded down to the hour, and stores it as a table property that downstream sensors can wait on. The Spark upsert job copies the watermark to the base table. The work is built on generic Accumulator and CommitProcessor extension points in an extensible Flink-Iceberg sink, and tables can choose percentile-based policies to trade completeness for freshness.
- Handling Time-Variant DAGs with Constraints in Postgres
Neon mediumAdept
Vehicle attachments in a fleet (trucks pulling trailers) are modeled as a time-variant DAG in a single Postgres table of edges with validity intervals and a source-authority priority. Deferred constraint triggers run PL/pgSQL checks at commit to reject cycles and overlapping incoming edges per node, so multi-statement batches can proceed before validation. An add_edge() helper resolves conflicts by truncating, splitting or deleting overlapping intervals according to priority. Recursive CTEs with temporal filters then answer point-in-time snapshots and downstream traversal queries; full code is open source.