synchronous-replication · shipping

Synchronous replication

Synchronous replication makes successful completion depend on acknowledgement that a specified set of replicas has reached the processing stage required by the replication contract.

Related Observatory article: Read on hesela.com

Name the acknowledgement boundary instead of assuming that synchronous means query-visible. PostgreSQL 18 distinguishes a standby filesystem write, durable WAL flush and transaction replay; configured synchronous standbys are required for remote waiting. This database usage is broader than a storage contract requiring completed remote disk writes. Required replicas add latency and their unavailability can block commits.

In PostgreSQL 18.0, canceling a synchronous-replication wait can end the wait for a transaction already committed locally while standby replication may still be incomplete. The QueryCancelPending path issues a warning and ends the wait; it cannot undo that commit. This is not a rule that all canceled statements commit. [5]

The commit path retains locks during that wait and still lists the transaction as running, despite its recorded local commit. Local commitment and immediate visibility to other sessions are different boundaries. [6]

In libpq, PQcancelBlocking returning 1 confirms dispatch of a cancellation request, not rollback or completed remote replication. The client must still process the original connection's response. Warnings go to a notice handler, separately from the query result. [7] [8] [9]

Operational inference: in the late synchronous-wait path above, absence of a query error alone does not establish that the requested remote boundary was reached. Preserve the warning as well as the query result before deciding whether to retry. [5] [9]

Relations

related
Asynchronous replication, Replication lag, Mirroring (storage), I/O fencing, Chain replication, Log sequence number, Hot standby feedback

Limitations

  • Operational inference: a standby read conflict can delay following WAL records and extend a remote_apply wait when that standby's acknowledgement is needed; another sufficient quorum may avoid that dependency. [10, 1, 2]
  • PostgreSQL 18.0 releases queued replication waiters after the primary processes a configuration change that empties synchronous_standby_names. Operational inference: record policy changes alongside commit outcomes; success after disabling synchronous waiting does not certify acknowledgement under the previous standby requirement. [5, 2]

Citations

  1. PostgreSQL 18: WAL settings, synchronous_commit (accessed 2026-10-12)
  2. PostgreSQL 18: synchronous_standby_names (accessed 2026-10-12)
  3. PostgreSQL 18.0: synchronous replication waiting, cancellation and policy changes (accessed 2026-11-02)
  4. PostgreSQL 18.0: local commit ordering before synchronous replication wait (accessed 2026-11-01)
  5. PostgreSQL 18: libpq cancellation dispatch, section 32.7.1 (accessed 2026-11-01)
  6. PostgreSQL 18: cancellation request and original query response, section 54.2.8 (accessed 2026-11-01)
  7. PostgreSQL 18: libpq notice and warning processing, section 32.13 (accessed 2026-11-01)
  8. PostgreSQL 18: standby query conflicts and replay, section 26.4.2 (accessed 2026-11-01)

Further reading

  1. PostgreSQL 18: warm standby and synchronous replication (accessed 2026-10-12)
  2. Replication acknowledgements: received, durable, applied (accessed 2026-10-12)
Sources & caveats
  • PostgreSQL 18.0 source-code review, not a replication experiment; cancellation behavior is scoped to the late commit-wait path. [5] [6]
  • PostgreSQL 18 client API and protocol documentation distinguish dispatch, query results and warnings; retry advice is editorial inference, not a tested driver recipe. [7] [8] [9]
  • PostgreSQL 18 standby conflict and delay documentation reviewed on 2026-11-01; the acknowledgement dependency is source-derived, not a measured latency result. [10] [1] [2]

JSON: /data/terms/synchronous-replication.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Synchronous replication. Hesela. 2026-11-02. https://hesela.dev/terms/synchronous-replication/