Quick revision
The short answer
I would define durability tiers by data class instead of letting each team choose settings. Tier 1, payments and ledgers, must survive the loss of one node with no committed data lost: synchronous_commit = on with synchronous replication to at least one standby (synchronous_standby_names = 'ANY 1 (...)'), or in MySQL innodb_flush_log_at_trx_commit = 1 and sync_binlog = 1 with semi-synchronous replication, accepting the extra commit latency. Lower tiers may relax durability per transaction, never by silently editing a global default, failover tooling must refuse to promote a lagging replica for tier 1, and the settings are managed, checked for drift, and proven by regular failover tests with measured RPO.
What to remember
In this answer, we saw how to replace scattered durability settings with a company standard. We define tiers by data class with explicit RPOs, configure tier 1 for zero loss on a single node failure with synchronous_commit = on and a quorum of synchronous standbys in PostgreSQL, or flush-at-commit and semi-synchronous replication in MySQL, and allow lower tiers to relax durability only explicitly. Failover tooling must not promote a lagging replica for tier 1 without an operator's decision, the settings are managed and checked for drift, failover is tested with measured RPO, and applications use idempotency keys for ambiguous commits.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would define durability tiers by data class instead of letting each team choose settings. Tier 1, payments and ledgers, must survive the loss of one node with no committed data lost: synchronous_commit = on with synchronous replication to at least one standby (synchronous_standby_names = 'ANY 1 (...)'), or in MySQL innodb_flush_log_at_trx_commit = 1 and sync_binlog = 1 with semi-synchronous replication, accepting the extra commit latency. Lower tiers may relax durability per transaction, never by silently editing a global default, failover tooling must refuse to promote a lagging replica for tier 1, and the settings are managed, checked for drift, and proven by regular failover tests with measured RPO.
Why this question is asked
The incident in the question is a classic: a commit was acknowledged, the primary failed, a replica that had not yet received the last few seconds was promoted, and payments that clients saw as successful were gone. Nothing was broken; the settings simply allowed it, and nobody had decided that they should. Interviewers ask this to see whether a senior engineer can turn scattered knobs into a deliberate standard. In this answer, we will recap where a commit can be lost, define tiers, set tier 1 for PostgreSQL and MySQL, handle lower tiers, make failover respect the tiers, manage and test the settings, and cover what applications must still do.
1A Quick Recap: Where a Commit Can Be Lost
A commit is durable on one server when its log record has been flushed to disk before the commit is acknowledged. In PostgreSQL that is synchronous_commit = on, in MySQL innodb_flush_log_at_trx_commit = 1 for the InnoDB redo log and sync_binlog = 1 for the binary log. Relaxing these makes commits faster but lets a crash lose the last moments of acknowledged commits.
Replication adds a second place where commits can be lost. With asynchronous replication, the default in both databases, the primary acknowledges the commit before any replica has it. If the primary fails and a replica is promoted, whatever had not reached the replica is lost. That is what happened to the payments team: their RPO, recovery point objective, the amount of data we can lose in a failure, was a few seconds, without anyone choosing that.
2Define Durability Tiers by Data Class
The standard starts from the business, not the database. Each data class gets a tier with an explicit RPO and a latency expectation.
| Tier | Data | RPO | Typical settings |
|---|---|---|---|
| 1 | payments, ledgers, orders | 0 on loss of one node | local flush + sync standby (ANY 1) |
| 2 | user data, configuration | under 1 s | local flush, async replicas, close lag alerts |
| 3 | activity logs, metrics, sessions | seconds acceptable | synchronous_commit = off per transaction |
Notice that tiers are assigned to data, so one database cluster carries the tier of its most critical data. A cluster holding payments is tier 1 even if it also stores some logs, and the logs can relax durability per transaction, as we will see.
3Tier 1 Settings for PostgreSQL and MySQL
For tier 1, a commit must be on disk on the primary and on at least one standby before it is acknowledged. In PostgreSQL that means synchronous replication with a quorum, so one slow standby does not block commits if another is healthy.
Notice the cost: every commit now waits for a network round trip to a standby and its disk flush, often one to a few milliseconds within a region and much more across regions. That is the price of RPO zero, and the standard says so openly so teams can plan for it. With two standbys and ANY 1, losing one standby does not stop commits. MySQL's semi-synchronous replication falls back to asynchronous after rpl_semi_sync_source_timeout if no replica acknowledges, which silently weakens the guarantee, so tier 1 sets a long timeout and alerts on the fallback; check the variable names for your version, since older releases used master and slave.
4Lower Tiers, Relaxed Explicitly
Some data does not deserve that latency. PostgreSQL lets durability be relaxed for a single transaction, which is better than lowering a global setting that every other transaction silently inherits.
The rule in the standard is that relaxing is allowed only explicitly, per transaction or per role for a documented data class, and never by editing the cluster default. A value such as synchronous_commit = local, which flushes locally but does not wait for the standby, also fits tier 2 transactions on a tier 1 cluster.
5Failover Must Respect the Tier
Synchronous settings are only half the story; the other half is what happens at failover. Automated failover tools such as Patroni can promote a replica when the primary disappears. For tier 1, the tool must only promote a replica that is known to have every acknowledged commit, a synchronous standby, and must refuse to promote one that is behind unless an operator explicitly accepts data loss.
- Primary lostdetected by failover manager
- Synchronous standby available?YesPromote it: RPO 0NoDo not promote automatically
- Operator accepts data loss?YesPromote lagging replica, record decisionNoWait and restore primary
- Reconcile after failovercompare with payment provider records
4 steps in order. Play them, or step through them one at a time.
Promotion of a lagging replica is an explicit, recorded decision.
Patroni has a synchronous mode and limits on lag at failover for this purpose, and managed database services have equivalent options; check the exact settings for your version or provider. The important thing is that promoting a lagging replica is a business decision, made by a person, recorded, and never a silent default.
6Manage, Check and Test the Standard
Settings written in a wiki drift. The standard is published as managed configuration, templates in the infrastructure code or parameter groups in the managed service, keyed by tier. A scheduled check compares every cluster's live settings with its tier and alerts on drift, such as a tier 1 cluster whose synchronous_standby_names is empty after a maintenance.
Finally, failover is tested regularly, for example quarterly per tier 1 cluster in a controlled window: write a stream of numbered transactions, kill the primary, let the tooling fail over, and count which acknowledged transactions survive. The measured RPO, zero for tier 1, is the proof the standard works.
7What the Application Must Still Do
No database setting removes one problem: the ambiguous commit. If the connection drops after the client sent COMMIT but before it received the answer, the client cannot know whether the payment committed. Retrying blindly risks a double payment; giving up risks a lost one. So the standard also requires idempotency keys for tier 1 operations: the client sends a unique key with each operation, the database stores it with a unique constraint in the same transaction, and a retry with the same key returns the original result instead of executing twice.
8Follow-up questions
How do you handle a commit whose acknowledgement was lost?
Treat the outcome as unknown and resolve it by asking. The client retries with the same idempotency key, and the server either finds the key, meaning the first attempt committed and the stored result is returned, or does not, meaning it never committed and the operation runs now. Without such a key, the client would have to query by business attributes, which is fragile.
Why ANY 1 rather than requiring all standbys?
Requiring every standby means any single standby failure or slowness blocks all commits. ANY 1 of two or three standbys keeps RPO zero for the loss of the primary while tolerating the loss of a standby, which is the right balance for most tier 1 systems.
Does synchronous replication protect against a region outage?
Only if a synchronous standby is in another region, which adds cross-region latency to every commit. Many companies keep tier 1 synchronous within a region across zones and accept a small RPO for full region loss, but that must be a stated decision in the standard.
9Conclusion
In this answer, we saw how to replace scattered durability settings with a company standard. We define tiers by data class with explicit RPOs, configure tier 1 for zero loss on a single node failure with synchronous_commit = on and a quorum of synchronous standbys in PostgreSQL, or flush-at-commit and semi-synchronous replication in MySQL, and allow lower tiers to relax durability only explicitly. Failover tooling must not promote a lagging replica for tier 1 without an operator's decision, the settings are managed and checked for drift, failover is tested with measured RPO, and applications use idempotency keys for ambiguous commits.
Open with
What happened is that commits were acknowledged before any replica had them, so promoting an asynchronous replica lost them. Nobody chose that RPO, it came from defaults. I would define durability tiers by data class.
Then, if they want more
Tier 1 is payments, ledgers and orders: no committed data lost when one node fails.
In PostgreSQL that means synchronous_commit on and synchronous_standby_names with ANY 1 of two standbys, so a commit is flushed locally and on one standby before it is acknowledged; in MySQL, innodb_flush_log_at_trx_commit 1, sync_binlog 1, and semi-synchronous replication with AFTER_SYNC and an alert if it falls back to async. We accept a few milliseconds of extra commit latency and say so.
Lower tiers can relax durability, but only explicitly, for example SET LOCAL synchronous_commit off for activity logs, never by changing a global default. Failover must match: Patroni or the managed service may only auto-promote a synchronous standby for tier 1, and promoting a lagging replica needs an operator to accept data loss explicitly.
The settings live in managed configuration per tier, a job checks for drift, and we test failover regularly by writing numbered transactions, killing the primary and measuring the RPO. Finally, applications use idempotency keys, so a client whose commit acknowledgement was lost can retry safely without double payments.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- MySQL 8.4
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
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 "Different teams set PostgreSQL synchronous_commit, MySQL innodb_flush_log_at_trx_commit...": https://scrivio-interview-library.netlify.app/databases/acid-and-isolation/40f74b3e6c/