Executive Summary
1 min summary
During a payment or ledger migration, every transaction needs a single authoritative owner, even while old and new systems run in parallel. Shadow processing, per-operation reconciliation (not just aggregate totals), explicit amount scaling, and durable idempotency keys catch divergences before the new service moves live money. Define clear go/no-go gates, assign every reconciliation exception to a real owner, and plan for the moment when rolling back a feature flag stops being safe.
A new settlement service can pass every unit, contract, and staging test and still fail the first day it meets production traffic. Lay its records next to the old ledger and you find three transactions missing, two processed twice, and a balance nobody can explain.
When that happens in shadow mode, you got lucky: you found the gaps before switching live traffic. A crash is loud and obvious. Far more dangerous is a pair of payment services that keep returning 200 OK while quietly disagreeing about what happened to someone’s money.
In Lost in a Forest You Built, I covered how to carve a settlement domain out of a scaling monolith without stopping the business. The moment two ledgers run side by side, though, a sharper question takes over: which one actually owns the truth?
One System Must Own the Record
Before picking a database or messaging broker, decide which system has final authority over each transaction.
During shadow processing, the old ledger remains the system of record: it accepts the live transaction, drives the existing workflow, and serves as the baseline for comparison. The new service calculates what it would have done, and its output stays strictly observational.
Two independent services writing to two databases will disagree for mundane reasons: one write commits while the other times out, a message arrives late, or a retry runs twice. Dual writes across separate databases are never atomic, and a 200 OK from one side proves nothing about the other.
In practice, I prefer a transactional outbox on the authoritative database (typically PostgreSQL in the fintech platforms I work on): commit the business change and the outgoing event in the same local transaction, then relay that event to the new service, which deduplicates deliveries and records its own result. Change data capture (CDC) can work too, provided your team understands its ordering guarantees, replay behavior, and recovery steps. Neither pattern eliminates reconciliation, yet both give you a traceable path from the authoritative commit to the shadow copy.
Document this explicitly: For every transaction type and migration phase, which ledger is authoritative, which service is allowed to initiate an external money movement, and who resolves a disagreement?
The answer can vary by customer cohort or payment rail. It can never be ambiguous for a single transaction.
Give Every Transaction a Trail (and Never Assume a Fixed Scale)
Before you compare two systems, agree on how to match records across them.
A stable transaction ID needs to travel from the originating request through both implementations and into logs, reconciliation tables, and partner references wherever the provider allows it. A single payment also spawns distinct operations (authorization, capture, refund, settlement, reversal), and each operation needs its own stable ID so a legitimate follow-up isn’t mistaken for a retry.
Keep field semantics identical across both sides, especially amounts and timestamps. Never assume two timestamps mean the same thing: one system may store when an event occurred, another when it was persisted, and a third when the bank settled it.
Amount representation is where silent ledger bugs love to hide. On one integration I worked on, our platform standardized on euro amounts stored with four decimal places, dividing incoming values by a hardcoded constant. Then we integrated a local payment provider in Brazil that sent amounts scaled to eight decimal places. Because the conversion assumed our usual fixed divisor, the ledger started recording numbers orders of magnitude too high for every transaction from that provider.
Nothing crashed, and every validation passed, until reconciliation surfaced the inflated balances. Always store exact integer minor units alongside an explicit scale (or currency-and-provider precision) and currency code, never a floating-point number or an implicit divisor.
Finally, mark the starting line. If the new ledger is seeded from a snapshot of existing balances, record the exact cut-off point where the snapshot ends and live event streaming begins. Test that boundary deliberately with transactions arriving mid-snapshot, duplicate deliveries, and out-of-order events, because an off-by-one gap at the seam will poison every balance comparison that follows.
Once every transaction carries a trail and a clean starting seam, you can run live traffic through the replacement ledger without touching real money.
Shadow the Work Without Moving Money
Shadowing lets the replacement service chew through real production traffic while the old path still owns live execution.
Enforce that isolation in code and infrastructure, not by convention. A shadow service must be physically unable to send a duplicate payout instruction, trigger a refund, or email a customer. Stub or block outbound payment adapters at the boundary, and verify those blocks in failure tests so a misconfigured environment variable cannot accidentally fire live instructions.
Start with a bounded slice of traffic and compare individual operations and accounting entries, never just aggregate totals.
The offsetting-total trap: One missing €500 payment and one duplicated €500 payment leave the daily aggregate balance spotless while two customers have broken accounts.
Reconcile across three boundaries using the same time window and finality rules:
- Old ledger vs. new ledger: Did both systems see the same operations and produce matching entries and states?
- Internal ledger vs. external evidence: Do your records match processor confirmations and bank settlement files?
- Period totals by account and currency: Do closing balances agree once known in-flight items are accounted for?
Separate timing lag from real breaks. A wire waiting on bank settlement is different from an item still missing after its cutoff window; never dump both into one generic “mismatch count.”
Remember too that matching the old system proves consistency, not correctness. Legacy payment code almost always hides undocumented quirks or old bugs, so investigate every divergence against business rules and bank evidence before teaching the new service to copy a historical mistake.
Catching discrepancies automatically still leaves the hardest operational question: who owns fixing them?
Put Every Exception in Someone’s Hands
Automated reconciliation detects discrepancies; humans have to resolve them.
Every exception needs enough context for an engineer or finance operator to see whether real money or only a shadow record is affected, and what action is safe. I like backing the exception queue with an explicit, auditable table rather than Slack alerts or ephemeral logs:
CREATE TABLE reconciliation_exceptions (
exception_id UUID PRIMARY KEY,
tx_id TEXT NOT NULL,
operation_id TEXT NOT NULL,
currency CHAR(3) NOT NULL,
amount_minor BIGINT NOT NULL,
amount_scale SMALLINT NOT NULL, -- e.g. 4 vs 8; never assume a single divisor
old_state TEXT NOT NULL,
new_state TEXT NOT NULL,
category TEXT NOT NULL, -- timing_lag | missing_event | duplicate | rule_diff | external_mismatch | unexplained
owner TEXT NOT NULL,
status TEXT NOT NULL, -- open | investigating | resolved | accepted
first_seen_at TIMESTAMPTZ NOT NULL DEFAULT now(),
resolved_at TIMESTAMPTZ,
resolution_note TEXT
);
Set an SLA for each category: how long a timing_lag can sit before escalating, and when an unexplained or external_mismatch row pages on-call. Keep an immutable audit trail of every resolution, and never silently adjust a balance just to turn a dashboard green.
Even a disciplined exception queue breaks down the moment a network timeout hits mid-payment.
Retries Are Not Permission to Pay Twice
Networks drop packets, and timeouts are the nastiest failure mode in payments: when a request times out, you don’t know whether it failed before reaching the provider or succeeded and lost the response on the way back.
Assign a stable idempotency key to each intended operation and reuse that exact key on every retry. Persist the key alongside the outcome, enforce uniqueness in the database, and reject reuse if the payload conflicts. Crucially, that key must survive the handoff between old and new services. If the new service generates a fresh idempotency key after cutover, a retry of an old attempt turns into a second payment.
Read your payment provider’s idempotency contract carefully. Check how long they retain keys (24 hours? 7 days?), what scope they enforce, and how you query an uncertain operation. When a response is ambiguous, query the provider’s recorded state before deciding whether to retry. If the provider cannot confirm the outcome, escalate to operations rather than guessing it failed.
Inside the migration pipeline, build every consumer to handle duplicate and out-of-order deliveries cleanly. Before cutover, rehearse four uncomfortable failure scenarios and write down the recovery steps while everyone is awake:
- The old database commits, but event delivery to the new service stalls.
- The new service receives the same event twice.
- The external provider accepts a payment, but the HTTP response times out.
- A refund arrives while the original capture is still in an uncertain state.
Mark the Handover Before Changing Tracks
A feature flag can route HTTP traffic to a new service, but flipping a flag alone does not safely transfer financial authority.
Move one bounded cohort or payment rail at a time, and agree on the promotion criteria before looking at the shadow results: a shadow run covering full settlement cycles and edge cases, zero unresolved material discrepancies for that cohort, rehearsed recovery runbooks, and explicit sign-off from both engineering and finance/operations.
At the moment of handover, verify the new ledger has caught up to a known watermark and fence off the old writer. That often means briefly draining or pausing the cohort and writing an explicit ownership marker (for example, cohort_owner = 'new_ledger' checked inside the write transaction) so a late-arriving message cannot cause the old service to fire an instruction after cutover. Account for every in-flight operation by ID and decide up front which system completes it.
Once the cohort is live, monitor the new authoritative path against bank settlement files, the exception queue, delivery lag, and customer-facing errors. A quiet first hour proves very little; keep the cohort under close watch through at least one full settlement cycle before expanding the rollout.
When Rollback Stops Being Simple
While the new service is still in shadow mode, backing out is easy: turn off the shadow consumer and the old system keeps running.
The moment the new service accepts live writes or sends external payment instructions, flipping the feature flag back stops being a real rollback. The old ledger is now missing every transaction processed since cutover, and external transfers have already left the building.
Any serious rollback plan has to answer three questions: how the old ledger will backfill and verify the activity it missed, how you prevent duplicate instructions during the switchback, and what happens to in-flight payments. If you rely on reverse synchronization to keep rollback viable, test it under load before cutover.
If reverse sync isn’t built or isn’t trustworthy, be honest about it upfront: your real recovery strategy is to pause the affected cohort and repair forward under single-owner control.
External money movements cannot simply be rolled back in a database transaction. Reversing them means issuing a refund, reversal, or compensating entry under provider rules and financial controls, which requires finance sign-off as much as engineering work. Before approving any cutover, ask one blunt question: “If we have to stop two hours in, what happens to the money that already moved?”
Four Gates Before I Sign Off on a Cutover
When I review a payment or ledger migration plan during a 2-week architecture review, I look for four hard gates. If any of them comes back with “we’ll figure that out during cutover,” the migration isn’t ready:
- Enforced single authority. One ledger owns each cohort at any given moment, backed by a fencing check in the write path, and the shadow service is blocked from triggering external money movement.
- Full-cycle reconciliation with explicit scale. Per-operation comparisons (not just daily totals) have run across at least one complete bank settlement cycle, with exact minor-unit + scale handling and every material break resolved or signed off by finance.
- End-to-end idempotency across the seam. Idempotency keys survive the handoff from old service to new, and the team has actually tested timeouts, duplicate events, and mid-flight refunds against the real failure runbook.
- An honest post-cutover recovery plan. Either reverse synchronization has been tested end-to-end, or engineering and finance both agree in writing that past the point of no return, the team pauses the cohort and repairs forward.
Any replacement service can return 200 OK. A replacement ledger earns authority by making every discrepancy visible, proving where every cent went against external evidence, and giving the people responsible for the money a safe way to act when something goes wrong.
Planning a payment or settlement migration? Review our Payment & Ledger Migration readiness signals on GitHub, explore the Pointer Assessment and Legacy Modernization, or let’s discuss your migration risks.