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
- Check why log file cannot be reused using the following query:
select name, log_reuse_wait_desc from sys.databases where name='dbname'
- 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
We can check why the transaction log is full as follows:
We can take log backup to truncate the log file in the above scenario.
Scenario 2
Here transaction log file is growing due to replication failure. We have to troubleshoot the replication issue.