Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

Transaction Log Full Issue in SQL Server

4.64/5 (4 votes)
9 Oct 2013CPOL1 min read 54.1K  
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)