Azure PostgreSQL Flexible Server: Abnormally high synchronous WAL commit latency in PROD

Satyam Sinha 0 Reputation points
2026-10-23T10:51:00.8566667+00:00

We are experiencing abnormally high transaction commit latency on our Azure Database for PostgreSQL Flexible Server in PROD.

SQL execution itself is fast (<1 ms), but synchronous transaction commits consistently take approximately 76–110 ms, with observed spikes up to 259–389 ms.

We compared this with our INT environment, where commits typically complete in approximately 1–1.5 ms.

Zone-redundant HA has already been disabled in PROD, but the high commit latency remains.

PostgreSQL sessions have been observed waiting on IO / WALSync and LWLock / WALWrite.

A controlled test further isolated the issue:

synchronous_commit = off:
insert: 0.21–0.30 ms
commit: 0.03–0.17 ms

synchronous_commit = on:
insert: 0.22–0.58 ms
commit: 76.54–389.13 ms

WAL generation during our sampling period was low, approximately 2–7 KB/sec, and wal_buffers_full remained 0.

We also observed approximately 104–106 committed transactions/sec; however, the amount of WAL generated was very low.

pg_stat_bgwriter did not change during the sampled slow-commit interval, so there was no observed checkpoint activity corresponding to that interval.

PostgreSQL version:

PostgreSQL 16.15

track_wal_io_timing is read-only on this Azure Flexible Server and WAL timing counters therefore remain unavailable/zero.

Based on these observations, the latency appears concentrated in the synchronous WAL durability/flush path rather than SQL execution or HA replication.

Azure Database for PostgreSQL

1 answer

Sort by: Oldest
  1. Alex Burlachenko 26,215 Reputation points MVP Volunteer Moderator
    2026-10-23T12:42:22.9733333+00:00

    Hi Satyam Sinha & thx for join me at Q&A platform,

    ur testing points pretty strongly toward WAL flush latency rather than slow SQL execution, especially with the difference between synchronous_commit=on and off.

    The most useful evidence is that inserts consistently finish in under 1 ms, while synchronous commits take 76–389 ms. With synchronous_commit=off, the commit latency drops to almost nothing. Combined with the IO/WALSync wait events, that suggests PostgreSQL is spending a significant amount of time waiting for WAL durability operations to complete.

    Disabling zone-redundant HA was a reasonable test, but it doesn't eliminate the requirement to flush WAL to durable storage for local commits. So the fact that latency remains high with HA disabled makes synchronous standby replication less likely to be the explanation, but it doesn't rule out storage-side latency.

    I'd also pay attention to the LWLock/WALWrite waits. Those can indicate contention between backends trying to write or flush WAL. If one backend is experiencing a slow flush, other concurrent transactions may end up waiting behind it. That could explain why ur commit latency occasionally reaches 300–400 ms even with relatively low WAL generation.

    The low WAL throughput and unchanged checkpoint counters are useful observations, but neither rules out a storage problem. Small synchronous writes can have high latency even when total IOPS and throughput are low. And WAL flushing is separate from normal checkpoint activity.

    I'd compare PROD and INT at the infrastructure level next: compute SKU, storage configuration, provisioned IOPS, storage utilization, and Azure Monitor disk I/O metrics. Look for differences in write latency, IOPS consumption, throttling, or disk queue behavior around the affected timestamps. Also check whether the problem persists during low-traffic periods with only one connection performing small transactions.

    One particularly useful test would be to run the same controlled transaction workload against PROD and INT with a single connection, then repeat with multiple concurrent connections. If PROD still shows 76–110 ms commits with only one active writer, that would make application-level contention a less convincing explanation and put more focus on the WAL durability path.

    I wouldn't recommend disabling synchronous_commit globally as a workaround. It reduces commit latency by allowing PostgreSQL to acknowledge transactions before their WAL records are durably flushed, which introduces a potential data-loss window if the server crashes.

    Also, track_wal_io_timing being read-only is a managed-service limitation, so I wouldn't spend more time trying to enable it. You've already collected enough evidence to justify a deeper investigation.

    At this point, I'd open an Azure Database for PostgreSQL Flexible Server support case and request service-side storage and WAL flush latency diagnostics. Include the PROD/INT comparison, exact UTC timestamps, PostgreSQL version, compute and storage configurations, wait-event samples, and the controlled synchronous_commit test results.

    Specifically, ask engineering to check whether the underlying storage path is experiencing elevated flush latency, whether any I/O throttling is occurring, and whether there are host-level or service-side conditions affecting WAL durability operations.

    A consistent 76–110 ms synchronous commit time compared with 1–1.5 ms in INT is a substantial difference, and I wouldn't consider it normal without an explanation tied to the actual infrastructure configuration.

    One question: are PROD and INT using the same compute tier, VM size, storage type, and provisioned IOPS? If they're comparable and PROD still shows this behavior under a single-connection test, that would strengthen the case for an Azure-side investigation quite a bit.

    rgds,

    Alex

    p.s. if my answer is help - pls mark it as an answer

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.