HADR_DATABASE_FLOW_CONTROL Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: HADR_SYNC_COMMIT Wait TypeRelated pillar: High Availability
⚡HADR_DATABASE_FLOW_CONTROL is an Availability Group primary pausing sends for a database because too many messages to a secondary are still unacknowledged. It is only an issue if network sends are slower than expected. Run the check to see the send queue and send rate per database and replica.

Microsoft’s definition: waiting for messages to be sent to the partner when the maximum number of queued messages has been reached. It indicates the log scans are running faster than the network sends, which is an issue only if network sends are slower than expected. Its Availability Group performance page describes two levels of flow control gates on the primary, one per replica and one per database, which stop sending once a message threshold is reached until acknowledgements bring the count back down. This wait is the database-level gate.


Is It a Problem?

Small amounts on a busy AG are the gate doing its job. It matters when it grows, because sustained flow control means the pipeline to a secondary is the bottleneck, and on synchronous replicas that surfaces as HADR_SYNC_COMMIT, which users feel as slow commits. Get Wait Statistics does not filter it out, so if it ranks, you will see it.

Judge it over an interval rather than the cumulative totals. The baseline to monitor is log_send_queue_size per database draining after bursts; rising flow control with a growing send queue means the network or the secondary cannot keep up.


Common Causes

  • Network throughput or latency between replicas too low for the log generation rate, common with secondaries in another site or region.
  • Log-heavy work, such as index rebuilds and bulk loads, producing bursts well above the normal rate.
  • A slow secondary, with a slow log disk or redo falling behind.
  • Older builds with the lower gate limits, below.

The Check To Run

Rank it against everything else with Get Wait Statistics, then read the send and redo queues per database and replica on the primary:

SELECT
    ar.replica_server_name,
    DB_NAME(drs.database_id) AS database_name,
    drs.synchronization_state_desc,
    drs.log_send_queue_size,
    drs.log_send_rate,
    drs.redo_queue_size,
    drs.redo_rate
FROM sys.dm_hadr_database_replica_states AS drs
JOIN sys.availability_replicas AS ar ON ar.replica_id = drs.replica_id
ORDER BY drs.log_send_queue_size DESC;

A send queue that keeps growing while log_send_rate stays flat is the link or the secondary. Check Always On Availability Group Latency reads the same view with more context. The query needs VIEW SERVER STATE.


What To Do

  1. Compare the log generation rate on the primary with what the link carries. If generation is higher, reduce log volume, for example by trimming index maintenance and batching loads, or improve the link.
  2. Check the secondary: log disk latency and redo queue.
  3. Know the version. SQL Server 2022 raised the number of messages each gate allows; on SQL Server 2019 CU9, 2017 CU18 and 2016 SP1 CU16 and later, trace flag 12310 at startup gives the higher limits, and it cannot be set with DBCC TRACEON. Test before using it.

The HADR Commit and Flow Waits

These are the Availability Group waits on the path a commit takes from the primary to its secondaries: capturing log, sending it, waiting for it to harden, and the controls that throttle it. The main page is HADR_SYNC_COMMIT.

  • HADR_SYNC_COMMITSynchronous commit. The primary waiting for a synchronous secondary to harden the log.The main page for this family
  • HADR_DATABASE_FLOW_CONTROLFlow control. Sends paused because the queue of unacknowledged messages is full.Worth a look when it climbs. This page.
  • HADR_TRANSPORT_FLOW_CONTROLTransport flow control. Sends to one replica paused because too many messages to it are unacknowledged.Worth a look when it climbs
  • HADR_GROUP_COMMITGroup commit. Commits held briefly so several fit into one log block; expected.Worth a look when it climbs
  • HADR_LOGPROGRESS_SYNCLog progress. Concurrency control while updating each replica’s log progress.Worth a look when it climbs
  • HADR_LOGCAPTURE_WAITLog capture. Waiting for log records to become available; expected when caught up.Usually noise
  • PREEMPTIVE_HADR_LEASE_MECHANISMLease. The Availability Group lease manager scheduling.Worth investigating
  • HADR_SEEDING_LIMIT_BACKUPSAutomatic seeding. Recorded during automatic seeding; reported as long and benign.Worth a look when it climbs

Where To Go Next

If HADR_DATABASE_FLOW_CONTROL is climbing, these are the next places to look.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *