Guides

The transaction log for database is full due to 'LOG_BACKUP' (Msg 9002): fix and prevent it

By Scott Coffey, Senior Database Developer. Updated 2026-11-20.

Inserts and updates start failing, and every write to one database returns the same error:

Msg 9002, Level 17, State 2, Line 1
The transaction log for database 'Sales' is full due to 'LOG_BACKUP' and the holdup lsn is (49:2359:1).

Recent versions add the "holdup lsn" part; older ones end after the reason. Reads still work. Anything that needs to write to the log does not.

The reason in quotes is the important part. LOG_BACKUP means the database is in the FULL (or BULK_LOGGED) recovery model, so SQL Server keeps every log record until a log backup has copied it. If log backups never run, or stopped running, the log grows until it hits its size limit or the disk fills, and then writes fail.

A common way to get here: a database is created in FULL recovery (often because model is set that way), someone takes a full backup, and nobody schedules log backups. Until that first full backup the log truncates on checkpoint much like SIMPLE, so the problem only shows up later.

Step 1: confirm the reason

SELECT name, recovery_model_desc, log_reuse_wait_desc
FROM sys.databases
WHERE name = N'Sales';

log_reuse_wait_desc = LOG_BACKUP confirms what the error said. If it shows something else, the fix is different: ACTIVE_TRANSACTION means an open transaction is holding the log (see Step 5), and values such as REPLICATION or AVAILABILITY_REPLICA point at a log reader or a secondary that is behind.

Step 2: check size, used space, and growth limits

USE Sales;
SELECT total_log_size_in_bytes / 1048576.0 AS log_size_mb,
       used_log_space_in_percent
FROM sys.dm_db_log_space_usage;

SELECT name, size * 8 / 1024 AS size_mb,
       CASE max_size WHEN -1 THEN 'unlimited'
            ELSE CAST(max_size * 8 / 1024 AS varchar(20)) END AS max_mb,
       CASE is_percent_growth WHEN 1 THEN CAST(growth AS varchar(10)) + '%'
            ELSE CAST(growth * 8 / 1024 AS varchar(10)) + ' MB' END AS growth
FROM sys.database_files
WHERE type_desc = N'LOG';

Used space near 100% with size_mb equal to max_mb means the file hit its cap. If the cap is unlimited, the drive is probably full. DBCC SQLPERF(LOGSPACE) gives the same used-percent figure for every database at once.

Step 3: find the last log backup

Check every database that needs log backups, not just the one that failed:

SELECT d.name, d.recovery_model_desc,
       MAX(b.backup_finish_date) AS last_log_backup
FROM sys.databases AS d
LEFT JOIN msdb.dbo.backupset AS b
       ON b.database_name = d.name AND b.type = 'L'
WHERE d.recovery_model_desc <> N'SIMPLE'
  AND d.database_id > 4
GROUP BY d.name, d.recovery_model_desc
ORDER BY last_log_backup;

A NULL means no log backup has ever been recorded on this server. An old date usually means a log backup job is failing or disabled. Check its history with the queries in the Agent job failure guide.

Step 4: take a log backup and verify it

A log backup is the fix, and it works even when the log is completely full. Use a unique, timestamped file name and a checksum:

DECLARE @file nvarchar(260) = N'D:\SQLBackups\Sales_LOG_'
      + FORMAT(SYSDATETIME(), 'yyyyMMdd_HHmmss') + N'.trn';

BACKUP LOG Sales TO DISK = @file WITH CHECKSUM, STATS = 10;
RESTORE VERIFYONLY FROM DISK = @file WITH CHECKSUM;

Re-run the Step 1 and Step 2 queries. log_reuse_wait_desc should return to NOTHING and used space should drop. The file keeps its size; the space inside it becomes reusable. Keep that backup file. It is part of the log chain you need for a point-in-time restore.

If the backup cannot be written because the backup drive is full too, point it at another volume with space. As a short-term measure you can also raise the log file's MAXSIZE with ALTER DATABASE ... MODIFY FILE, or add a second log file on another drive, then remove it once the log is healthy.

Fixes to avoid. Switching the database to SIMPLE frees the log but breaks the log chain, so you lose point-in-time restore until the next full or differential backup. If the database truly does not need point-in-time recovery, make that change on purpose, not as an emergency fix. Backing up to NUL has the same effect, because the log records are thrown away. Never delete the .ldf file. Shrinking the log right away just makes it grow again later; consider DBCC SHRINKFILE only after log backups are running and you know the normal size.

Step 5: if the space does not come back, look for an open transaction

A log backup can only free log records older than the oldest active transaction. In our test on SQL Server 2022, with one session holding a transaction open, a log backup completed but used space stayed at 99.99% and log_reuse_wait_desc still said LOG_BACKUP. After that transaction ended, one more log backup freed the space. So check:

USE Sales;
DBCC OPENTRAN;

SELECT s.session_id, s.status, s.login_name, s.host_name, s.program_name,
       dt.database_transaction_begin_time,
       ib.event_info AS last_statement
FROM sys.dm_tran_database_transactions AS dt
JOIN sys.dm_tran_session_transactions AS st ON st.transaction_id = dt.transaction_id
JOIN sys.dm_exec_sessions AS s ON s.session_id = st.session_id
OUTER APPLY sys.dm_exec_input_buffer(s.session_id, NULL) AS ib
WHERE dt.database_id = DB_ID()
ORDER BY dt.database_transaction_begin_time;

An old transaction from a sleeping session is usually a forgotten BEGIN TRAN or an application that never commits. Treat it the way the head blocker guide describes: find the owner before you kill anything, because KILL rolls the work back, and a long rollback also uses log.

Step 6: schedule log backups and alert on 9002

Log backups should run on a schedule that matches how much data you can afford to lose, often every 15 minutes, from a SQL Server Agent job with failure notification. The SQL Rig agent-job-create-template.sql creates the job disabled with a dry run by default, and the full pack's Backup-SqlDatabase.ps1 wraps the same backup without dbatools:

# Preview the exact BACKUP LOG statement first, then run it
.\Backup-SqlDatabase.ps1 -ServerInstance SQL01 -Database Sales `
    -BackupDirectory 'D:\SQLBackups' -Type Log -Verify -WhatIf

It writes timestamped files with CHECKSUM, refuses a backup folder that does not exist, and never deletes old backups, so retention stays a deliberate decision.

Then add an alert so the next 9002 reaches a person before users do. On Windows, Agent alerts respond to errors written to the Application log, and 9002 is one of them (is_event_logged = 1 in sys.messages):

EXEC msdb.dbo.sp_add_alert
     @name = N'Error 9002 - Transaction log full',
     @message_id = 9002,
     @severity = 0,
     @delay_between_responses = 300,
     @include_event_description_in = 1;

EXEC msdb.dbo.sp_add_notification
     @alert_name = N'Error 9002 - Transaction log full',
     @operator_name = N'DBA Team',
     @notification_method = 1;

SQL Rig's agent-job-failure-alert.sql creates the operator and the severity 19-25 and 823/824/825 alerts in the same idempotent, dry-run-first way; 9002 fits the same list. Finally, rerun the Step 3 query weekly, or add it to a health check, so a database that drifts into FULL recovery without log backups is caught early. The pack's task-backup-restore-verify.md prompt asks an AI agent for this full plan: a backup schedule based on recovery model, verify steps, a restore-to-dev test, and Agent scheduling.