- Error number
- 9002
- Severity
- 17 (resource or software problem)
- State
- 2 (LOG_BACKUP) or 4 (ACTIVE_TRANSACTION)
- Product
- Microsoft SQL Server Database Engine
- Versions
- All supported SQL Server versions (2016 to 2025), Azure SQL Managed Instance
- Category
- Log & Storage Space
- Last reviewed
- 23 October 2026
On this page
What it means
Error 9002 means the database cannot write to its transaction log: the log file is full, cannot grow, and none of its space can be reused yet, so changes stop until you free or add log space.
Every change is written to the transaction log before it is considered done. Log space is reused only after the records in it are no longer needed: backed up (in the FULL or BULK_LOGGED recovery model), committed, replicated or sent to availability group secondaries. When nothing can be reused and the file cannot grow, SQL Server raises 9002 at severity 17 (insufficient resources) and the statement fails.
The word in quotes, for example LOG_BACKUP or ACTIVE_TRANSACTION, is the reason the log cannot be reused, and it is the same value as log_reuse_wait_desc in sys.databases. SQL Server 2025 also prints the holdup LSN, the log sequence number of the oldest record that is still needed. Fix the reason, not the symptom: shrinking a full log does not help, because there is no free space to release.
Common causes
LOG_BACKUP: the database uses the FULL (or BULK_LOGGED) recovery model but log backups are not running, so the log only grows.ACTIVE_TRANSACTION: one long or forgotten open transaction keeps every log record after it alive, for example a large batch update in a single transaction or a session that never committed.AVAILABILITY_REPLICA,DATABASE_MIRRORINGorREPLICATION: a secondary replica, mirror or replication reader has not yet received the log records.- The log file has autogrowth disabled, has reached its MAXSIZE, or the volume it lives on is full.
Diagnose it
Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.
Read why the log cannot be reused
SELECT name, recovery_model_desc, log_reuse_wait_desc
FROM sys.databases
WHERE name = N'AppDb'; The log_reuse_wait_desc value matches the reason in the message and chooses the fix. NOTHING means the log can already be reused (the pressure has passed).
See how full each log is
-- Log size and percent used for every database on the instance
DBCC SQLPERF(LOGSPACE); Log Space Used (%) close to 100 for the affected database confirms the log is full.
Check whether the log file can grow
SELECT mf.name, mf.physical_name,
mf.size / 128 AS size_mb,
CASE mf.max_size WHEN -1 THEN 'unlimited' ELSE CAST(mf.max_size / 128 AS varchar(20)) + ' MB' END AS max_size,
mf.growth, mf.is_percent_growth,
vs.available_bytes / 1048576 AS volume_free_mb
FROM sys.master_files AS mf
CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.file_id) AS vs
WHERE mf.database_id = DB_ID(N'AppDb')
AND mf.type_desc = 'LOG'; growth = 0, size_mb equal to the max size, or very little volume_free_mb means the file cannot grow.
When were the last log backups taken?
SELECT TOP (5) backup_start_date, backup_finish_date
FROM msdb.dbo.backupset
WHERE database_name = N'AppDb'
AND type = 'L'
ORDER BY backup_finish_date DESC; No rows, or nothing recent, with LOG_BACKUP as the reason: log backups are missing.
Find the oldest open transaction
Run in the affected database when the reason is ACTIVE_TRANSACTION.
DBCC OPENTRAN;
SELECT s.session_id, s.login_name, s.host_name, s.program_name,
t.transaction_begin_time
FROM sys.dm_tran_active_transactions AS t
JOIN sys.dm_tran_session_transactions AS st ON st.transaction_id = t.transaction_id
JOIN sys.dm_exec_sessions AS s ON s.session_id = st.session_id
ORDER BY t.transaction_begin_time; The session that has held a transaction open for a long time, with its login, host and program, so you can ask its owner to commit or roll back.
How to fix it
Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.
Take a log backup (reason LOG_BACKUP)
Changes database stateIn the FULL recovery model, a log backup marks the backed-up part of the log as reusable. Back up to a location you keep: the log backup is part of your restore chain. One backup may not be enough if the active part of the log is large; check log_reuse_wait_desc again afterwards.
BACKUP LOG AppDb
TO DISK = N'D:\Backups\AppDb_log_20261023_1400.trn';
End the long-running transaction (reason ACTIVE_TRANSACTION)
Changes database stateAsk the owner of the session found above to commit or roll back. Ending the session is the last resort: its work is rolled back, and rolling back a large transaction can itself take a long time and needs log space.
Caution: KILL rolls back all uncommitted work in that session. Confirm with the owner first and never kill a session you have not identified.
-- Last resort, after identifying the session (replace 57 with its session_id)
KILL 57;
Give the log room to grow
Changes configurationIf the file is capped or autogrowth is off, raise MAXSIZE and set a fixed growth increment. If the volume is full, free space there, or add a second log file on another volume as a temporary measure and remove it once the cause is fixed.
ALTER DATABASE AppDb
MODIFY FILE (NAME = AppDb_log, MAXSIZE = 32GB, FILEGROWTH = 1GB);
Fix the secondary, mirror or replication reader (AVAILABILITY_REPLICA, REPLICATION)
Read-onlyThe log is waiting for another component. Check that availability group secondaries are connected and synchronising (sys.dm_hadr_database_replica_states) and that the replication Log Reader Agent is running. Once they catch up, the log becomes reusable without further changes on the primary.
SELECT DB_NAME(database_id) AS database_name, synchronization_state_desc,
log_send_queue_size, redo_queue_size
FROM sys.dm_hadr_database_replica_states;
Switch to the SIMPLE recovery model only if point-in-time restore is not needed
Changes configurationIn SIMPLE recovery the log is reused after each checkpoint, so missing log backups can no longer fill it. This is a decision about how much data you can afford to lose, not a quick fix: get agreement from whoever owns the data first.
Caution: Switching to SIMPLE breaks the log backup chain: you can no longer restore to a point in time, only to the last full or differential backup. If you switch back to FULL later, take a full or differential backup immediately to start a new chain.
ALTER DATABASE AppDb SET RECOVERY SIMPLE;
Examples
FULL recovery with no log backups
A throwaway database with a 1 MB log that cannot grow, in FULL recovery after one full backup. Inserts fill the log because no log backup frees it.
-- Setup (throwaway database): log SIZE = 1MB, MAXSIZE = 1MB, FILEGROWTH = 0
ALTER DATABASE AppDb SET RECOVERY FULL;
BACKUP DATABASE AppDb TO DISK = 'NUL'; -- starts the log chain; NUL discards the backup
CREATE TABLE dbo.Big (id INT IDENTITY PRIMARY KEY, pad CHAR(4000) NOT NULL DEFAULT 'x');
DECLARE @i INT = 0;
WHILE @i < 5000 BEGIN INSERT dbo.Big DEFAULT VALUES; SET @i += 1; END;
SELECT log_reuse_wait_desc FROM sys.databases WHERE name = N'AppDb';
Msg 9002, Level 17, State 2, Line 7 The transaction log for database 'AppDb' is full due to 'LOG_BACKUP' and the holdup lsn is (44:264:1). log_reuse_wait_desc LOG_BACKUP
Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.
How to prevent it
If a database uses the FULL recovery model, schedule log backups (often every 5 to 15 minutes) and alert when they fail. If nobody needs point-in-time restore, choose SIMPLE deliberately rather than leaving the default.
Size the log for your largest maintenance and batch work, use a fixed growth increment, and monitor log percent used and volume free space. Break very large modifications into batches that commit, so one transaction cannot hold the whole log. Data files filling up is a different error: see error 1105.
Common questions
Should I shrink the log file to fix error 9002?
No. When the log is full there is no free space to release, so a shrink does nothing for the error. Fix the reason in log_reuse_wait_desc first (usually a log backup or a long transaction). Shrinking a log that later needs to grow again only adds growth pauses.
What does the holdup LSN in the message mean?
It is the log sequence number of the oldest log record that is still needed, which is where reuse is blocked. SQL Server 2025 adds it to the message; earlier versions show only the reason in quotes.
Why does 9002 happen even though I take full backups every night?
Full backups do not free log space in the FULL recovery model; only log backups do. Either schedule log backups or, if point-in-time restore is not needed, use the SIMPLE recovery model.
Learn more on CodeWithSQL
Official documentation
- Troubleshoot a full transaction log (SQL Server Error 9002)
- MSSQLSERVER_9002 (Microsoft Learn)
- Recovery models (SQL Server)
Last technically reviewed 23 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.