Solved

Transaction Log for database XXX is full

Posted on 2016-08-31
5
103 Views
Last Modified: 2016-09-12
Hi Experts,

I am working with SQL 2008 and have an issue with the transaction log for the database being full. I ran a check on the log_reuse_wait_desc and the error was LogBackup and the log_reuse_wait=2.

How do I resolve this issue?

Thanks
0
Comment
Question by:Member_2_7964761
5 Comments
 
LVL 39

Expert Comment

by:lcohan
ID: 41778714
USE testdb
GO
CHECKPOINT
GO
DBCC SHRINKFILE (N'testdb_log' , 0, TRUNCATEONLY)
GO
-- or:
BACKUP LOG testdb TO DISK='NUL:'

But you need to have a FULL backup prior to this just in case.
0
 
LVL 13

Expert Comment

by:Nakul Vachhrajani
ID: 41778715
Please check the recovery mode of the database. If it is the full recovery model, the only way to free up space in the log is to take a log backup.

Is this a production database, or a database that is primarily used only for ad-hoc development and testing? If it is used only for ad-hoc purposes, you can evaluate setting the recovery model to "Simple". Do keep in mind though that setting the recovery model to "simple" will impact your ability to recover the database in case of a failure.
1
 
LVL 39

Expert Comment

by:lcohan
ID: 41778718
Also you need to check the recovery model and if that is FULL you must perform regular FULL + T-Log backups to reclaim T-log space otherwise it will get full again.
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 250 total points
ID: 41778814
You have two choices.

1) Take a log backup.  Depending on the log size, this could take a long time.  While you're doing that the db will remain unuseable.  But it keeps the backup/log chain intact.  If you would really ever want to apply an overgrown log to recover the db, you need to use this method.

2) Put the db into SIMPLE recovery model and shrink the log file.  Then, if you need to, set recovery back to FULL and immediately (or asap) take a full db backup.

USE [XXX]
ALTER DATABASE [XXX]  SET RECOVERY SIMPLE;
CHECKPOINT;
DBCC SHRINKFILE (2, 4096);
EXEC sp_helpfile /*verify that the log file is really smaller*/

Btw, learn to use SQL commands such as those above to work on the log.  Do not use the SSMS gui for this, as it can be flaky.  Besides, it's easier to repeat if you use commands, and you'll have a record of exactly what was done, which you won't get from a gui.
0
 
LVL 4

Assisted Solution

by:Daniel Jones
Daniel Jones earned 250 total points
ID: 41779260
First change Recovery Model to Simple
  • Database Propertise > Options > Recovery Model > Simple

Then Shrink Files Log
  • Database > Shrink > Files > Log

Then check your db log file size at
  • Database Propertise > Files > Database Files > Path

To check full sql server log: open Log File Viewer at
  • SSMS > Database > Management > SQL Server Logs > Current

Do you have Enable Autogrowth and Unrestricted File Growth for the log file. You can edit these via
  • SSMS > Database Properties > Files
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question