Why Does the SQL Server Transaction Log Grow in Simple Recovery?

SQL Server Problems

Published

A production SQL Server raised a disk space alert. One database log file occupied almost the entire drive, even though the database used the SIMPLE recovery model. It was tempting to read the alert as evidence of recent transaction log growth. But when had the file actually grown? It could have reached that size during an import days before the warning appeared.

Under SIMPLE, a checkpoint allows SQL Server to reuse parts of the log once it no longer needs the records they contain. A busy job can use up the available space before then. If autogrowth is enabled and the drive has room, SQL Server can extend the file to keep writing. Once the space inside becomes reusable, the file keeps its size. From the disk monitor’s point of view, a busy log and a mostly empty one can look much the same.

When we checked the database, SQL Server reported ACTIVE_TRANSACTION. That gave us something specific to investigate at the time of the alert. Establishing what had caused the file to reach its current size would take more than that one reading.

What does a nearly full log drive tell you?

Suppose a 20 GB log file takes up most of a dedicated drive. The overnight import has finished, and SQL Server reports just 3 GB in use. Windows still sees a 20 GB file, but much of the space the next import needs is already there. SQL Server can write new log records into reusable parts of that file without asking Windows for another allocation.

SQL Server transaction log wrapping from the end of a physical log file back to its beginning
The logical log can wrap around within the same physical file as earlier space becomes available for reuse. Source: Microsoft Learn.

Now picture the same drive halfway through the import. The log has 19.8 GB in use, more orders are coming in, and the volume has little room left. The disk warning looks exactly as it did in the first example. This time, the import may need more space before SQL Server can reuse any. It matters whether the next configured growth increment will fit on the drive.

During an incident, I’d run this query in the affected database and take a second reading while the job is still running.

SELECT
    SYSDATETIME() AS sample_time,
    DB_NAME() AS database_name,
    d.log_reuse_wait_desc,
    CAST(l.total_log_size_in_bytes / 1048576.0 AS decimal(18,1)) AS total_log_mb,
    CAST(l.used_log_space_in_bytes / 1048576.0 AS decimal(18,1)) AS used_log_mb
FROM sys.dm_db_log_space_usage AS l
JOIN sys.databases AS d ON d.database_id = l.database_id;

Read used_log_mb alongside total_log_mb. If only the first value rises, the workload is using space SQL Server has already allocated. An increase in the second tells you the database has more log space allocated than it did at the previous sample. Check the file’s maximum size and autogrowth setting while you have those figures in front of you. Extra room on the volume only helps if SQL Server can use it.

When did transaction log growth actually occur?

On a shared log volume, start by checking which files changed size. A large LDF file can have occupied the same space for months. A smaller file belonging to a different database may have grown just enough this morning to cross the warning threshold. If the ticket names only the largest file, the DBA can spend an afternoon investigating a database whose storage requirements barely changed.

The disk alert gives you a time for the threshold crossing. A recorded transaction log growth event gives you a time for the file extension. Job history tells you when the work started and finished. Put those observations on the same timeline. If the file grew before the nightly import started, that run cannot explain the first extension. If both began together, look at the import and any work that overlapped with it.

Sometimes all you have is a disk graph and a successful job entry. A job can finish successfully after several growth events, and a disk graph cannot identify a database transaction. I’d record what the graph establishes and arrange to capture file growth and used log space during the next run. If users also reported a slowdown, keep their timestamps. The same comparison can help you narrow down why SQL Server suddenly felt slow.

How an open transaction can drive transaction log growth

Imagine an application that opens a transaction, updates one order and waits for another service to respond. While it waits, an import on a separate connection writes thousands of orders to the same database. The import commits each batch as it goes.

With traditional recovery, SQL Server still needs the log record for that first update in case the application rolls it back. The open transaction can keep a whole stretch of the log active, including records from import batches that have already committed. On a busy system, that stretch can grow quite large while the application waits. You could halve the import’s batch size and still have the same session holding up reuse.

Which session is holding up log reuse?

This is where I’d follow up on ACTIVE_TRANSACTION. Run DBCC OPENTRAN in the affected database while SQL Server still reports the condition. Capture the start time of the oldest active transaction and its session ID where available. Those details give you something to match against the job history or the application’s own logs. A sleeping session is worth a look. It can have work left uncommitted even though it has no request running. DBCC OPENTRAN reference

The application owner can often explain what happens between the order update and the commit. Does the application contact another service inside the transaction? What does it do if that call times out? A timeout in the application log is a useful lead if its timing matches the open transaction. The developer now has a specific execution path to inspect. The last SQL statement alone rarely tells you what happened next in the client.

One database setting matters when you interpret this example. Accelerated Database Recovery (ADR) uses row versions during rollback. That can let SQL Server truncate the log earlier, even while a long transaction remains open. On a database with ADR enabled, the age of a session alone is a poor basis for explaining file growth. How accelerated database recovery works

What can you change while the job is still running?

Suppose the import owner confirms that the job is processing its final batch. Used log space is rising, but the drive and the file settings allow another growth increment. Letting the batch finish while watching the next readings may be the least disruptive choice. The decision changes if the application is waiting indefinitely for a response and nobody can identify a path to commit. Additional capacity can buy time to investigate. Someone still needs to establish how that transaction will end.

Before ending a session, find out what SQL Server will have to undo and what the application will do afterwards. Under traditional recovery, rolling back a large transaction can take time. Meanwhile, a scheduler may already be preparing a retry. If that retry starts during rollback, the on-call team has two pieces of work to account for. Agree with the job owner on who controls the retry and how they will confirm which batches committed.

If you extend the volume, take a fresh reading from both Windows and SQL Server. More free space on the drive tells you the storage change succeeded. A later sample showing the file growing into that space tells you the database could use it. Keep the original readings with the ticket. Once the pressure eases, they may be the only record of how quickly the remaining capacity was disappearing.

Does recurring transaction log growth justify a larger file?

For a sizing decision, I’d want readings from a representative run. Start collecting used and allocated log space before the job begins and follow it through its busiest phase. Check again after the final commit and a checkpoint. Keep the job timings with those readings. An import that overlaps with month-end processing may need considerably more room than it does on an ordinary Tuesday.

Ask the people who own the job what a representative run looks like. A warehouse team may call a load “daily” even though Mondays include the entire weekend. An ERP team may use the same job name for ordinary posting runs and for a much larger year-end close. Those details matter more to the sizing decision than the average of a week’s worth of quiet mornings.

If the import uses most of the file each night and that space becomes available again by morning, I’d keep the allocation. Shrinking it every morning would make the next import wait for SQL Server to allocate that space again. The observed peak also gives the storage team a basis for deciding how much room to leave for a busier run.

There are cases where I’d reclaim some of the space. Suppose the application team has fixed a code path that left a transaction open. Subsequent imports and a month-end close have used only a fraction of the file. A one-time shrink may be reasonable if another workload needs that storage. The peak across those runs is a better starting point for the target size than the figure from a quiet morning. Microsoft guidance on sizing and shrinking the transaction log

What should the next disk alert tell you?

A dedicated log drive can spend much of its life above a percentage threshold that made sense when the volume was empty. Changing the threshold to alert later may cut the number of tickets. It also gives the team less notice if another workload starts consuming the remaining capacity. Before changing it, express the free space in the same units as the configured growth increment. How many increments would fit, and how quickly did the busiest observed run consume that much space?

Keep a volume alert for the people who can extend storage. Alongside it, give the DBA a view of used log space and recent transaction log growth for each database on that volume. An alert arriving during month-end processing then has some context. The person looking at it can compare today’s run with the last close and identify which database is consuming space. That makes it easier to decide whether the application owner needs to join the call.

What would you check before extending the drive again?

For the original ticket, I’d want two measurements from the next representative run. How much log space did the job use at its peak, and did the file grow along the way? If the import fits comfortably inside the existing file, I’d review the alert threshold with the DBA and storage team. Another growth event while an older transaction holds up reuse would lead me back to the application owner before anyone orders more storage.

If your team has already extended the drive and the same warning is back, that’s a good time to bring me in. I can review the next run with your DBA and application owner. We can see when log usage starts to climb and check what the application is doing at that point. To get started, send me the alert and a few lines about what your team has seen so far.

Foto von John Matychuk auf Unsplash

Björn Peters

SQL Server Consultant • CraftedSQL

I help teams understand what’s happening in their SQL Server environments and make informed decisions about what to change.

Facing SQL Server performance issues?

Whether you're dealing with a performance issue, planning an upgrade, or reviewing your SQL Server architecture, let's start with a conversation.

Start a Conversation