In partnership with

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

Explain AG lag in one picture. One parcel, four stops. Can we lose data? Stops 1 to 3. How long to fail over? Stop 4. Are reports up to date? Stop 4. Why is the app slow? The synchronous secondary.

This week's post put two things together: performance, and the ability to see where the wait is happening. Today I want to show how to explain that in one picture. A picture that a manager, or a DBA who is just starting, can understand in a minute.

In short

  • In a SQL Server availability group, the log waits at one of four stops on its way to a secondary. Stops 1 to 3 are a data loss risk. Stop 4 means a longer failover and old data in reports.

  • In my lab, the lag column showed 0 while 4.46 GB waited at stop 4. A slow synchronous secondary showed no queue, only HADR_SYNC_COMMIT waits: 1,841 ms per commit.

  • Write for your readers, and for the decision makers who read you too.

This tip does three things. First, it gives you the picture, and the business question each part answers. Second, on this Thanksgiving week, a thank-you, and a word on why not every post is a deep dive. Third, a career tip: who else is reading your technical posts.

How do you explain availability group lag to a manager in one picture?

On Monday we followed the log through four stages, with a parcel. Here is the same parcel, but this time for someone who doesn't care about LSNs. A manager cares about two questions: "Can we lose data?" and "How long until we are back?"

AG lag in one picture: every change on the primary is a parcel on its way to a secondary. Stop 1, unsent, in the warehouse; stop 2, in flight, on the truck; stop 3, not hardened, at the door. If the primary is lost now, data at these three stops can be lost (RPO, on asynchronous replicas). Stop 4, not redone, in the box: the data is safe, but failover takes longer and reports read old data (RTO). A slow synchronous secondary: no parcel waits, the primary waits for every signature, so every user waits. In the SSMS Always On dashboard, Estimated Data Loss answers stops 1 to 3, and Estimated Recovery Time answers stop 4.

Every change on the primary is a parcel on its way to a secondary replica:

  1. In the warehouse (unsent). The log is still on the primary.

  2. On the truck (in flight). It was sent, but it hasn't arrived.

  3. At the door (received, not hardened). It arrived, but nobody signed for it. It isn't on the secondary's log disk yet.

  4. In the box (hardened, not redone). It is signed for and safe on disk, but not unpacked yet.

Now the part a manager needs. On an asynchronous replica, if the primary is lost at this moment, the parcels at stops 1, 2 and 3 can be lost. That is your data loss risk, the RPO. A parcel at stop 4 is safe. But before a failover finishes, the secondary has to unpack every box. So a full stop 4 means a longer failover, the RTO. And if people read reports from that secondary, they see old data.

There is one more case, and it surprises people: a slow synchronous secondary. No parcel waits there. The primary waits for every signature before it confirms a commit. So every user waits at the counter. The application gets slower, and no queue shows it. In Monday's lab, the log rate fell from 20 MB/s to about 3.6 MB/s, and each commit waited 1,841 ms.

That wait has a name in the engine: HADR_SYNC_COMMIT, in sys.dm_os_wait_stats (SQL Server 2012 and later). It covers the whole round trip. The primary sends the log, the secondary writes it to its log disk, and the acknowledgment comes back. The 1,841 ms per commit in the lab was this wait: its time divided by its count, in one 2-second sample on the primary. It tells you the synchronous secondary is the slow part. It doesn't tell you why. To split network from disk, look at the log write time on the secondary.

So the picture turns four technical stages into four business questions:

The question

Where to look

Can we lose data?

Stops 1 to 3

How long to fail over?

Stop 4

Are the reports up to date?

Stop 4

Why is the app slow?

The synchronous secondary (HADR_SYNC_COMMIT)

Store It. Search It. Analyze It. One Postgres

Your AI app generates three kinds of data at once: events, vector embeddings, and the analytics you run on top of them. The default move is three systems, three sets of tooling, and pipelines to keep them in sync.

TimescaleDB handles all three in the Postgres you already run.

Hypertables ingest events at scale. pgvector and pgvectorscale store and search embeddings. Continuous aggregates keep analytics live without re-querying everything.

Same SQL, same tools, one system to operate. No pipelines to sync, no drift, no second database to feed.

Point it at your heaviest workload and watch it stay fast as data grows. It's still Postgres. Start on Tiger Cloud and get $1000 in credits.

Why did the lag show zero while 4.46 GB waited?

This is the example I use when someone says "the lag is fine". In Monday's lab, I blocked redo on one secondary. The redo queue grew to 4.46 GB. The lag column, secondary_lag_seconds, stayed at 0 the whole time.

I measured the 4.46 GB with redo_queue_size, in sys.dm_hadr_database_replica_states. The lab ran SQL Server vNext CTP 1.2 on Linux, a pre-release build. But the lag behavior is not a quirk of that build. Microsoft Learn defines the lag column by hardening in SQL Server 2016 and later, and in Azure SQL Managed Instance.

The column wasn't wrong. It counts how far behind the secondary is on hardening. Every parcel was signed for, so for that column there was no lag. But all of them were still in the box. In the picture, a manager sees it at once: stop 4 is full. Failover would take longer, and reports would be old.

A table of numbers needs a DBA to read it. A picture lets the other person see it. That is why I built the replay page, and why I keep this picture for meetings and incident reviews.

Where this works: availability groups exist in SQL Server 2012 and later, on Windows and Linux. Azure SQL Managed Instance uses a distributed availability group for the Managed Instance link, so the same four stops apply there.

A note for Thanksgiving week: who else is reading your technical posts?

Here in the United States, this is Thanksgiving week, Dia de Ação de Graças for us Brazilians. A time to reflect, and a time to say thank you. So first: thank you for subscribing to this newsletter, and for reading it.

My goal with my two newsletters is to write deeper posts, with practical experience, real data, and a touch of career advice or tips to complete the picture. But not every post will be at that level. Each deep post takes more time and effort, and it drains your energy. This is a week to reflect and to rest, so it is good to dose what we do. A short tip like this one is part of that balance.

It's also important to put our effort into what is good for our readers. If you have a blog or a newsletter, or you publish articles from time to time, find out what your readers want. That is why, in a few days, you will get a short survey from me, asking what you want me to write about.

But don't write only for technical readers. Write also for the decision makers. The people who look at what you are doing and think: "Interesting. I want to talk to this person." That conversation can become a job offer, a contract, or another opportunity for you.

So mix three things: what you like to do, what is good for your readers, and this other angle. Ask yourself: besides my technical readers, who else could be reading this post? The picture above is a small example. It is a technical topic, written so a manager can follow it.

I can tell you, based on data, that it works. I work with data, and I have metrics for everything around my posts, in the newsletter and on LinkedIn. In the coming weeks I will share who reads my newsletters, in general numbers: roles and countries, no names. You will see how far this can go, not only for me, but for you too, depending on how you do it.

Your next step: put your own availability group in the picture

If you have an availability group, open SQL Server Management Studio. Right-click your availability group and select Show Dashboard. Choose Add/Remove Columns and add two columns: Estimated Data Loss (time) and Estimated Recovery Time (seconds).

For each secondary, write down where its parcels are. Estimated Data Loss above zero means parcels at stops 1 to 3. A high Estimated Recovery Time means a full stop 4. Do it at a quiet hour and at a busy hour.

If you have a synchronous secondary, also note the average HADR_SYNC_COMMIT wait at the same two hours.

If you'd rather have a script than a dashboard, the same numbers are in sys.dm_hadr_database_replica_states. log_send_queue_size is stop 1. redo_queue_size and redo_rate are stop 4. last_commit_time, on the primary and on the secondary, shows the data loss gap. Write your own query, save it in your repository, and schedule it. Reading this DMV is light, so it's safe on a busy server.

Then explain the picture to one person who is not a DBA, in two minutes. If they can tell you what "stop 4 is full" means, the picture works.

Thank you again for your time, and for subscribing. If this was useful and you think someone else can benefit from it, please share it. I appreciate it. Happy Thanksgiving, and a good long weekend to everyone. See you next time.

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 (AG)

A SQL Server feature that keeps copies of databases on other servers (replicas).

Decision maker

A manager, director or client who decides on budgets, hires or contracts.

Failover

Moving the primary role to a secondary replica.

HADR_SYNC_COMMIT

A wait on the primary: the time to send the log to a synchronous secondary, write it there, and get the acknowledgment.

Hardening

Writing the received log to the secondary's log file on disk.

Redo

Applying the hardened log to the data pages on a secondary.

RPO

Recovery point objective: how much data you can afford to lose.

RTO

Recovery time objective: how long you can afford to be down.

secondary_lag_seconds

How many seconds a secondary is behind on hardening. It doesn't count log waiting for redo.

Synchronous commit

The primary waits until the secondary hardens the log before a commit finishes.

Did this post help you?
Every post is free to read. No paywall. If this one helped, a tip is a simple way to say thanks and help the next one.
Other amount
Join 1 reader who has tipped

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.

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. The technical details are based on publicly available Microsoft documentation as of November 2026.