Scrivio Interview library
DesignIntermediate6 min read · updated 13 November 2026

An order flow spans four services with their own PostgreSQL databases: orders, payments, inventory and shipping. Each has backups and point-in-time recovery. After a storage failure, the payments database can only be restored to 10:42, while the other three are intact up to 11:00.

What inconsistencies does this create, and how would you design the system so one service can be restored and then brought back in line with the others?

After the restore, payments is missing everything taken between 10:42 and 11:00, while orders and shipping still refer to those payments, so orders look paid with no payment record and the provider holds charges our system no longer knows about. Restoring all four databases to 10:42 would make them agree but throw away 18 minutes of valid work everywhere. Instead we design for replay: services exchange events through a durable log such as Kafka with retention longer than the recovery window, the restored service rewinds its consumer offsets and reprocesses with idempotent handlers, reconciles against external sources of truth like the provider's records, and every service documents and drills how it rebuilds itself after a restore.

Why this question is asked

In a monolith, one database restore brings everything back to one consistent moment. With four services and four databases, each restore is independent, and a single service restored to an earlier time no longer agrees with the others. This is one of the less discussed costs of microservices, and interviewers ask about it to see whether we design for recovery as well as for normal operation. In this answer, we will look at the inconsistencies the restore creates, see why restoring everything to 10:42 is rarely right, and then design replay through a durable event log, reconciliation against external sources of truth, and a documented recovery procedure per service.

1What the Restore Breaks

Between 10:42 and 11:00, customers placed orders and paid for them. The orders database recorded each order as paid, shipping created shipments for some of them, and the payment provider charged the cards. Now the payments database has been restored to 10:42, so it has no record of any payment from those 18 minutes.

The result is a set of contradictions. Orders reference payment ids that do not exist. A refund request for one of those orders fails because payments cannot find the original charge. The provider's settlement report lists charges our payments service has never heard of, so finance cannot reconcile. And if payments assigns new ids from a sequence that was also rewound, it may reuse ids that orders already references for different payments, which is worse than a gap.

State after payments is restored to 10:42
ServiceData up toOrder 9001 (paid at 10:50)
Orders11:00Paid, payment id p-7781
Payments10:42No such payment
Shipping11:00Shipment created
Payment providerLiveCard charged, idempotency key ord-9001
Three systems know about the payment; the one that should own it does not.

2Why Not Restore All Four to 10:42?

Restoring orders, inventory and shipping to 10:42 as well would make the four databases consistent with each other. But it would discard 18 minutes of valid work in three healthy databases: orders, stock reservations and shipments, all of which happened in the real world. The provider would still hold the charges, warehouses may already be picking parcels, and customers would see their orders disappear.

So restoring everything trades one inconsistency for a larger one, with the outside world instead of inside our system. It is rarely the answer. We need a way to bring the one restored service forward to 11:00 instead.

3Design for Replay With a Durable Event Log

If services communicate through a durable event log such as Kafka, the restored service can rebuild what it lost. Suppose payments consumes an OrderPaymentRequested event from orders and publishes PaymentCaptured events. Kafka keeps events for a configured retention period, so the events from 10:42 to 11:00 are still there.

After the restore, we reset the payments service's consumer group to an offset from before 10:42, using the time-based offset lookup Kafka supports, and let it reprocess. For this to be safe, handlers must be idempotent: processing an event that was already applied, from just before 10:42, must not create a second payment. Each handler checks for an existing record with the same business key, such as the order id, before acting. And payments must not charge the card again: the provider's idempotency key, here derived from the order id, makes a repeated capture call return the original charge instead of a new one.

Java
# Rewind the payments consumer group to just before the restore point (service stopped first)
$ kafka-consumer-groups.sh --bootstrap-server kafka:9092 --group payments \
--topic order-payments --reset-offsets --to-datetime 2026-11-13T10:40:00.000 --execute
# TOPIC PARTITION NEW-OFFSET
# order-payments 0 1849302
# order-payments 1 1851177
# Restart payments: events from 10:40 to 11:00 are reprocessed; idempotent handlers skip duplicates

Notice the two minutes of overlap before 10:42. We rewind a little further than strictly needed, because idempotent handlers make duplicates harmless while a gap would lose data. Retention must be longer than the window we may need to replay; that is the subject of the follow-up below.

4Reconcile Against External Sources of Truth

Replay is not always complete. Some payments may have been started by a path that did not produce an event, or an event may have been published only after the database write that was lost. So we also reconcile against systems outside our databases. The payment provider's records list every charge with our idempotency key, so a reconciliation job can find charges with no matching payment row and recreate them.

More generally, cross-service reconciliation jobs compare orders, payments and shipments regularly and report gaps: paid orders with no payment, payments with no order, shipments for unpaid orders. These jobs are useful every day, catching ordinary bugs, and after a restore they become the safety net that confirms the system is consistent again.

Step throughBringing payments back in line
  1. Restore payments to 10:42point-in-time recovery
  2. Rewind consumer offsets to 10:40Kafka time-based reset
  3. Replay events with idempotent handlersduplicates skipped
  4. Reconcile with provider by idempotency keyrecreate missing rows
  5. Cross-service reconciliation clean?orders, payments, shipments
    YesReopen payments to trafficNoInvestigate the gaps

5 steps in order. Play them, or step through them one at a time.

5Make Recovery Part of Each Service's Design

The lesson is that every service should know how it rebuilds itself after a restore. Each service documents its recovery procedure: which topics it replays and from where, which external systems it reconciles against, and which downstream services may need to replay its own events. This belongs in the service's design documents, next to its API and data model.

Then the procedure is drilled. Restoring a single service to an earlier point in a test environment, while the others stay current, and running its recovery steps, is the only way to know they work. Drills also reveal handlers that are not truly idempotent, which is the most common reason replay fails.

6Follow-up questions

What retention would you set on the event topics to make this work?

Longer than the worst gap between a restore point and the failure, plus the time it takes to notice and recover. The gap depends on the backup design: with continuous WAL archiving it is minutes, but corruption may be found days later and force an older restore point. So many teams keep 7 days as a floor on topics used for recovery, and longer, 14 or 30 days, where corruption could go unnoticed, accepting the storage cost. Tiered storage in Kafka makes long retention cheaper by moving older segments to object storage. Compacted topics are not enough for this, because compaction drops intermediate events.

What if a handler is not idempotent?

Then replay can create duplicates, such as two payment rows for one order. The fix is to give every event a business key and store processed keys, or to make the write itself conditional, such as an insert that does nothing when the key already exists.

Could the outbox pattern help here?

Yes. With a transactional outbox, the database write and the event are committed together, so an event exists for every change, which makes replay complete instead of best effort.

7Conclusion

In this answer, we saw that restoring one service's database to 10:42 leaves it contradicting the others and the payment provider, and that restoring all four to 10:42 discards valid work. We designed for recovery instead: replay from a durable log with idempotent handlers, reconciliation against external sources of truth and between services, and a documented, drilled recovery procedure for every service.

What to say in the interviewAbout 90 seconds aloud

Open with

After the restore, the payments database has nothing from 10:42 to 11:00, while orders and shipping are current. So orders look paid but have no payment record, refunds for those orders fail, and the provider holds charges our system no longer knows about; if sequences were rewound we could even reuse payment ids.

Then, if they want more

Restoring all four to 10:42 would make them consistent with each other, but it throws away 18 minutes of valid orders and shipments that already happened in the real world, so that is rarely right. Instead I would design for replay.

If services exchange events through Kafka with retention longer than the possible recovery window, then after the restore we stop payments, reset its consumer group offsets to a bit before 10:42 using a time-based reset, and let it reprocess.

That only works if handlers are idempotent, keyed on something like the order id, and if provider calls use idempotency keys so we never charge twice.

Then I would reconcile against external sources of truth: the provider's records by idempotency key let us recreate any payment rows replay missed, and regular cross-service reconciliation jobs compare orders, payments and shipments and report gaps.

Finally, every service should document how it rebuilds itself after a restore, what to replay and what to reconcile against, and we should include single-service restores in our drills.

About this answer

Last updated
13 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What inconsistencies does this create, and how would you design the system so one...": https://scrivio-interview-library.netlify.app/architecture/high-availability/391959846f/