Msg 9002, Level 17, State 2, Line 4
The transaction log for database 'tinylogtest' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
This is much better than you get on SQL Server 2000:
Msg 9002, Level 17, State 2, Line 4
The log file for database 'tinylogtest' is full.
This has no helpful information at all. So, looking at the 2005 message, it's telling us to look in the sys.databases table for more info. Let's do that:
SELECT
log_reuse_wait_desc FROM sys.databases WHERE [name] = 'tinylogtest';
GO
And the result is:
LOG_BACKUP
That's pretty clear - take a log backup! Here are the various values this can take, from the Books Online entry for sys.databases:
- NOTHING
- CHECKPOINT
- LOG_BACKUP
- ACTIVE_BACKUP_OR_RESTORE
- ACTIVE_TRANSACTION
- DATABASE_MIRRORING
- REPLICATION
- DATABASE_SNAPSHOT_CREATION
- LOG_SCAN
- OTHER_TRANSIENT
Their meanings are explained in the Books Online entry Factors That Can Delay Log Truncation. Now if we take a log backup, the log can be truncated.
BACKUP
LOG tinylogtest to DISK = 'C:\tinylogtest\dummybackup.bck';
GO
And checking the state in sys.databases again returns:
NOTHING
Simple - but it's amazing how many times I see this problem on newsgroups and forums.
The long-running transaction case...
For this test, assume I've run the T-SQL above to create the database, put it into full recovery mode, take the first full backup, and then create the table. Now in a second connection, I'll create a long-running transaction:
BEGIN
TRANSACTION PAULSTRAN;
GO
INSERT
INTO tinylogtest..testtable VALUES (1, 'a');
GO
Note that the transaction hasn't been committed or rolled back. In the original connection, I'll execute the WHILE loop to fill up the log again. When we check sys.databases we get back:
LOG_BACKUP
So we take a log backup and check the state again. This time we get:
ACTIVE_TRANSACTION
We need to use the DBCC OPENTRAN command to find out what the long running transaction is:
DBCC
OPENTRAN ('tinylogtest');
GO
And we get back:
Transaction information for database 'tinylogtest'.