Prefer another language? Prefere receber em português? ¿Prefieres recibirlo en español? Choose here / Escolha aqui / Elige aquí

This time I won't write a lot in the post itself. I will describe the main points that I found interesting. But the most important part is not here. It is a link.
I invite you to visit the lab page, where you can replay a lab I built. The data in the replay is fixed, but it is real data. It came from a lab I had to set up last week: six SQL Server replicas in Azure, joined in a distributed availability group. I saved every metric, every sample, in a way that lets me run it again as a replay. You press Play and you see the log moving, sample by sample. And you see where it really waits.
In short
Log on its way to a secondary waits in one of four stages: unsent, in flight, received but not hardened, or hardened but not redone.
In a recorded SQL Server distributed AG lab, four faults put the log in different places. A slow log disk looked like a slow link.
A blocked redo built 4.46 GB while
secondary_lag_secondsshowed 0: that column measures hardening, not redo.
This post does three things. First, it explains the four places where the log can wait, in plain words. Second, it shows what each of the four faults in the lab did, with the real numbers. Third, it gives you a short exercise to do on the replay page.
Where does the transaction log wait on its way to a secondary replica?
In an availability group, every change on the primary is written to the transaction log. The primary sends that log to each secondary. The secondary writes it to its own log file. This is called hardening. Then the secondary applies it to the data pages. This is redo.
When a secondary falls behind, people ask: "How far behind?" That is a good question, but it is not enough. The better question is: where is the log waiting?
Think of a parcel delivery:
Unsent. The parcel is still in the warehouse. The log is still on the sender.
In flight. The parcel is on the truck. The log was sent but has not arrived.
Received, not hardened. The parcel is at the door, but nobody signed for it. The log is on the secondary, waiting for its log disk.
Hardened, not redone. The parcel is inside the house, still in the box. The log is safe on disk, but not applied yet. Readers on the secondary don't see those changes.

Each stage has a different cause, and a different fix. A slow network and a blocked redo can both show "the secondary is behind". But you don't fix them the same way.
Two of these stages come straight from a DMV, sys.dm_hadr_database_replica_states: unsent is log_send_queue_size, and hardened but not redone is redo_queue_size. The two in the middle have no column of their own. The lab page calculates them from byte counters on both ends. In flight is the bytes sent minus the bytes received. Received but not hardened is the bytes received minus the bytes hardened. Both ends are sampled every 2 seconds, but not at the exact same moment. So these two numbers are approximate. A short spike in them can be only a timing gap between two samples. Look for a trend over several samples before you act on them. For scale: during the steady load before each fault, in flight stayed at or under 1.9 MB on every path, and received but not hardened at or under 0.4 MB. In the slow log disk run, in flight reached about 260 MB.
Where this works. Availability groups and sys.dm_hadr_database_replica_states exist in SQL Server 2012 and later. Distributed availability groups came with SQL Server 2016. Since SQL Server 2016, the log stream to asynchronous replicas is compressed by default, and the stream to synchronous replicas is not. Azure SQL Managed Instance uses a distributed availability group for the Managed Instance link, and Microsoft Learn recommends watching redo_queue_size there too. Azure SQL Database has no availability groups to manage; for geo-replication it has sys.dm_database_replica_states, with the same queue columns. My lab ran SQL Server vNext CTP 1.2 on Linux (build 18.0.110.3), a pre-release build.
What is in the distributed availability group lab?
Six SQL Server replicas on Red Hat Enterprise Linux in Azure. Three in East US 2 and three in West US 2, one per availability zone, each with 4 vCPUs.
Two availability groups of three replicas each. Inside each group, one secondary is synchronous and one is asynchronous.
An asynchronous distributed availability group joins the two groups. node-1 is the global primary. node-4 is the forwarder: it receives the log from the first group and sends it on to the second.
So the log travels on five paths: P1 and P2 inside the first group, P3 between the regions, and P4 and P5 inside the second group. node-5 and node-6 are two hops away from the primary.
Data and log share one Premium SSD v2 disk per node: 3,000 IOPS, 125 MB/s.
A load generator writes a steady 20 MB/s of log. A collector reads every node every 2 seconds. Each run starts with about two minutes of steady load before any fault.
Recorded on Nov 17, 2026. Server names are replaced on the page.
⚠️ Lab only. To create the faults, the lab limits network traffic on a node and caps the disk I/O of the SQL Server service. It also starts a long query on a secondary to block redo. Never do this on a production server, or on a server other people use.
You may be wondering why there's a coffee ad in a technical post. You know what? Sometimes we need some coffee to really see where the log is piling up. 🙂
Your K-Cup Has Been Sitting in a Warehouse for Months
That grocery store pod? It was roasted long before it hit the shelf. Coffee starts losing flavor within weeks of roasting — which is why your morning cup tastes flat, no matter how nice your machine is.
Angelino's does it differently. A third-generation roaster in Los Angeles, they roast, grind, and seal every pod in-house for peak freshness, then ship it to your door within days of roasting. The difference is the first thing you'll notice: real aroma, real flavor, no bitterness.
Mix and match from 50+ specialty coffees, teas, and flavored blends — all Keurig®-compatible — and save more with every box you add, up to 34% off at 12+. Order once whenever you're running low, or subscribe for an extra 5% if that's easier. Entirely up to you.
New customers get 15% off their first order — applied automatically, no code needed.
Four faults, four places the log waited

Fault | Path | Where the log piled up | Peak |
|---|---|---|---|
Slow link, 8 Mbit/s | P3 | Unsent, on node-1 | 2.3 GB |
Slow log disk on node-6 | P5 | Unsent, on node-4 | 3.5 GB |
Redo blocked on node-3 | P2 | Hardened, not redone | 4.46 GB |
Slow disk on synchronous node-2 | P1 | Nowhere: commits waited | No queue |
In all four runs, only the path with the fault fell behind. The other paths stayed at zero.
How each fault was made, and how it was removed:
Fault | How it was made | How it was removed | Back to normal |
|---|---|---|---|
Slow link | Linux traffic shaping ( | Shaping removed on node-1 | P3 at zero in about 90 s |
Slow log disk | Write cap (systemd, cgroup v2) on the SQL Server service on node-6 | Cap removed | P5 at zero in about a minute |
Redo blocked | Long read on node-3, then | Read query stopped | Queue applied in about a minute |
Slow sync secondary | Same write cap, on node-2 | Cap removed | 20 MB/s within one sample |
The I/O cap was set on the SQL Server service (a Linux cgroup), not on the Azure disk. In every run, I removed the fault and watched the queues go back to zero before the next step.
Slow link: the log stays on the sender
I limited the traffic from node-1 to node-4, the cross-region path, to 8 Mbit/s. In about three minutes, 2.3 GB of log was waiting as unsent on node-1. The forwarder was 126 seconds behind.
The first limit I tried, 80 Mbit/s, did nothing. Why? SQL Server compresses the log stream to asynchronous replicas by default. It does not compress the stream to synchronous replicas. The lab's rows compress well. So 20 MB/s of log needed less than 80 Mbit/s on the network. A 100 ms delay also did nothing at this load. When I removed the limit, the backlog moved through each stage on node-4, then on to node-5 and node-6. It was back to zero in about 90 seconds.
Slow log disk: it looked like a slow link
This one surprised me. I capped the disk of node-6, an asynchronous secondary, at 150 IOPS and 4 MB/s. I expected the log to pile up on node-6, as received but not hardened.
It didn't. After about four minutes, P5 was 3.5 GB behind. About 90% of it was unsent, still on node-4, the sender. About 260 MB was in flight. Almost nothing waited on node-6.
Why? node-6 accepts log only as fast as it can write it: about 3 MB/s, with about 900 ms per log write. So the sender keeps the rest. This is SQL Server's flow control. The sender has two gates: one per replica and one per database. When too many messages wait for an acknowledgment, a gate closes and the sender stops sending for a moment. Here, the database gate closed. On node-4, HADR_DATABASE_FLOW_CONTROL grew from 43 waits (9 seconds in total) in the 128 seconds before the cap, to 768 waits (201 seconds) in the 218 seconds with the cap. The replica gate never closed. On the sender, a slow disk on the receiver and a slow link look the same. What tells them apart is the log write time on the receiver.
Redo blocked: the lag said zero
On node-3, I started a long read query. Then I ran one ALTER TABLE ... ADD on the primary. To apply that change, redo on node-3 needs a schema modification lock. The reader held a lock that blocked it. So the redo thread waited on LCK_M_SCH_M, behind the reader's session.
Redo on node-3 stopped completely: 0 MB/s. The redo queue grew at the full 20 MB/s, to 4.46 GB in about four minutes.
And here is the lesson: secondary_lag_seconds for node-3 stayed at 0 the whole time. Why? Microsoft Learn defines this column by hardening. It counts the seconds since the oldest log block that the primary has hardened but the secondary has not. On node-3, every block was hardened. It was only not applied. So the lag column was right by its own definition, and still blind to this case. The redo queue shows it. When I stopped the reader, the 4.46 GB was applied in about one minute.
This is how the column is defined in SQL Server 2016 and later, on Windows and Linux, and in Azure SQL Managed Instance. It is not a quirk of my pre-release build. Azure SQL Database geo-replication uses another view, sys.dm_database_replica_states, and there Microsoft says to watch the redo queue and the lag together. Do the same everywhere.

Slow synchronous secondary: no queue, but everything slows down
I applied the same disk cap to node-2, the synchronous secondary in the first group. This time there was no queue at all. That is how synchronous commit works: the primary waits until node-2 hardens the log before each commit finishes.
So the primary slowed down instead. The log rate fell from 20 MB/s to about 3.6 MB/s. Transactions fell from 355 to about 40 per second. Each commit waited 1,841 ms. When I removed the cap, the rate was back at 20 MB/s within one sample.
Compare it with the slow log disk above: the same cap. On an asynchronous secondary, it built a 3.5 GB queue and the primary didn't notice. On a synchronous secondary, it built no queue, and the application lost about 80% of its throughput.
Why a picture of the log flow helps
When you explain an availability group with a table of numbers, people get lost. I have seen it in presentations many times. A picture is different. You see the log leave the primary, and you see where it stops.
The page gives you several ways to look at the same run:
A flow strip for one path, from the sender to the receiver, through the four stages.
Bars over time, to see when each stage grows and when it drains.
A pie view, to see which stage holds most of the backlog right now.
The rate at each point, in MB/s, to see where the flow slows down.
The events list: click one to jump to the moment a fault started or ended.
Size and time are different questions. Size is how much log is behind. Time is how long that stage needs to drain at its current rate. A stage that is not draining at all is stalled, like the blocked redo.
This is useful for experienced DBAs, in a presentation or an incident review. But I built it most of all for people who are starting, or who find it hard to see the technical parts of a database operation. Seeing the log wait is easier than reading about it.
How to read the four stages on your own availability group
Stage grows | Usual cause | Look next at |
|---|---|---|
Unsent | Slow link, suspended, or slow receiver | Network, and the receiver's log write time |
In flight | Network latency or loss | Retransmits, latency |
Received, not hardened | Slow log disk on the receiver | Log write time on the receiver |
Hardened, not redone | Redo too slow, or blocked | Redo waits, blocking sessions |
None, but commits are slow | Slow synchronous secondary | Commit wait, achieved log rate |
What this replay can't tell you
Each scenario was recorded once. The numbers show that run on this hardware, not product limits.
The VMs were small (4 vCPUs), and data and log shared one disk.
The slow disks were made with a write cap in Linux. I did not compare that with a real slow disk, or with SQL Server on Windows.
"In flight" and "received, not hardened" are calculated from counters, so they are approximate.
In this pre-release build,
log_send_ratereturned values that only grew. The page calculates the sent rate from the log generated and the unsent queue instead.Also recorded but not on the page yet: a load ramp, serial redo, a suspended replica, and the loss of the primary.
Your next step: guess first, then press Play
Open the replay and try this. It takes about five minutes.
Pick the slow log disk run. Before you press Play, guess: on path P5, which of the four stages will grow? Write your guess down.
Press Play at 15x and select P5. Watch the flow strip and the bars. Was your guess right? Then read the explanation under the controls: which number tells you the receiver's disk is the cause, and not the link?
Now pick the blocked redo run and select P2. In "Numbers at this sample", watch two columns: "not redone" (the redo queue) and "lag (DMV)" (
secondary_lag_seconds). One of them grows. The other one doesn't move.
If you have an availability group at work, ask yourself one question: which of these two numbers does your monitoring alert on? If the answer is only the lag, add an alert on redo_queue_size too. A redo queue that keeps growing while the lag stays low is the blocked-redo picture.
References
Where the log piles up: replay the lab (lab.dbatopro.com)
sys.dm_hadr_database_replica_states (Microsoft Learn)
Troubleshoot log send queuing in an Always On availability group (Microsoft Learn)
Troubleshoot recovery (redo) queuing in an Always On availability group (Microsoft Learn)
Tune compression for availability group (Microsoft Learn)
Distributed availability groups (Microsoft Learn)
Managed Instance link best practices (Microsoft Learn)
Glossary
Term | What it means |
|---|---|
Asynchronous commit | The primary doesn't wait for the secondary. Commits are fast, but the secondary can fall behind. |
Availability group | A group of databases that SQL Server copies from a primary replica to one or more secondary replicas. |
Distributed availability group | Two availability groups joined together, usually in different regions. The second one gets the log from the first. |
DMV | Dynamic management view: a system view that shows the server's current state. |
Flow control | Gates on the sender that pause sending when too many messages wait for an acknowledgment. One gate per replica, one per database. |
Forwarder | The primary of the second group in a distributed AG. It receives the log and sends it on to its own secondaries. |
Hardening | Writing the received log to the secondary's log file on disk. |
| A wait for a schema modification lock. Here, redo waited for it behind a read query. |
Log send queue | Log still on the sender, not yet sent to the secondary. |
Log stream compression | SQL Server compresses the log it sends to asynchronous replicas, by default, to use less network. |
Redo | Applying the hardened log records to the data pages on a secondary. |
Redo queue | Log the secondary has hardened but not yet applied. |
Replay | Running the page again from saved samples, without the lab. |
| How many seconds a secondary is behind on hardening the log. It doesn't count log that waits for redo. |
Synchronous commit | The primary waits until the secondary hardens the log before a commit finishes. |
How I write: every post starts from my own notes and experience. I use AI tools to help draft and edit, and I review every word before it goes out.
The technical details in this post are based on publicly available Microsoft documentation as of November 2026.
Disclaimer: The views expressed in this article are those of the author and do not necessarily reflect the official policy or position of Microsoft. The author is a Microsoft employee.


