Click here to Skip to main content
15,886,095 members
Articles / Programming Languages / SQL
Tip/Trick

Transaction Log Full Issue in SQL Server

Rate me:
Please Sign up or sign in to vote.
4.64/5 (4 votes)
8 Oct 2013CPOL1 min read 53.5K   3   2
This tip discusses about the transaction log full issue in SQL Server

Introduction 

Let me discuss some basic point about transaction log file full problem in SQL Server. Generally there should scheduled transaction log backups to avoid this problem as database recovery model we maintain FULL. 

Listed below are some regular scenarios when transaction log file of SQL Server database grows: 

  • If there are no scheduled log backups or log backups are not working. 
  • If there are active transactions in the log file
  • If there are long running queries
  • In database mirroring if mirror server fails
  • In replication if distributor fails
  • If there is no disk space to grow the Transaction Log file
  • If bulk data was imported without dividing into multiple batches or transactions. 

Troubleshooting

  1. Check why log file cannot be reused using the following query:
    SQL
    select name, log_reuse_wait_desc from sys.databases where name='dbname'
  2. Depending on the 2nd column value, we have to troubleshoot by using the following solutions:
    • Backing up the log (in case of the above scenario)
    • Freeing disk space so that the log can automatically grow
    • Moving the log file to a disk drive with sufficient space
    • Increasing the size of a log file
    • Adding a log file on a different disk
    • Troubleshoot replication or mirroring issue

Sample Scenario

Image 1

We can check why the transaction log is full as follows:

Image 2

We can take log backup to truncate the log file in the above scenario.

Scenario 2

Image 3

Here transaction log file is growing due to replication failure. We have to troubleshoot the replication issue.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Instructor / Trainer OptimizeSQL Technologies
India India
Mr. Kareem Syed is a senior SQL Server Trainer and working as Technical Consultant.

You can visit my blog at
www.optimizesql.blogspot.in

Comments and Discussions

 
GeneralMy vote of 1 Pin
nethunter_00728-Jan-15 13:30
nethunter_00728-Jan-15 13:30 
QuestionMy vote of 1 Pin
Rob Eckert8-Oct-13 16:13
Rob Eckert8-Oct-13 16:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.