SQL Server Blog

SQL Server Log File Full at 2 TB Max with CDC: How We Recovered

Quick summary

For several versions of SQL Server, the maximum log file size was noted at 2 TB. If you ever reach that limit you could find yourself in a Disaster Recovery scenario.

Context

We received an emergency call from a client that noted that their SQL Server instances was unresponsive. (This was an Amazon RDS instance, although that didn’t play much into the ultimate root cause.) The client had some technical staff already looking at the issue, and when we joined the call we were informed that the transaction log for their main production database was completely full, and all transactional activity in the database had stopped.

For many versions, SQL Server has had a default maximum files size of 2 TB on transaction log files. Even though newer versions like SQL Server 2022 and 2025 may say “unlimited”, they aren’t truly unlimited. The current documentation notes that transaction log files still have a 2 TB maximum file size.

Investigation: Why log_reuse_wait_desc Showed REPLICATION

After a quick review, we confirmed that the transaction log for their main production database was completely full, and had reached the maximum size of 2 TB. The log reuse description in sys.databases showed “REPLICATION” as the cause for the log being full.

This instance did not have replication, but the client did have Change Data Capture (CDC) enabled on numerous tables, which also shows up as “REPLICATION” in the lof reuse information. We discovered the CDC capture and cleanup jobs had not been running for weeks, which caused the transaction log to hold transactions and not mark them for reuse.

Unfortunately, before we joined the call, the client had enabled CDC thinking that would “clean up the log”, but what that did in the immediate moment was fill up the log faster as it generated more transactions to update data in the CDC support tables.

So now the file was already at the 2 TB limit, meaning it couldn’t be grown further. But here’s the biggest problem: any other solution to reduce the log file size at this point would not work because…it would involve a logged transaction. And the log was full.

Possible solutions include:

  • Disable CDC – that’s a logged transaction
  • Add another log file – that’s also a logged transaction
  • Declare it a disaster and restore the entire database from the most recent backups

The fix – kill another transaction and add another log file

We wanted to avoid restoring the database from backup, as that could mean further hours of downtime as well as more lost transactions. We determined the best possible solution was to try to Kill one of the smaller queries using the transaction log, and then quickly add another log file. It took several tries, but eventually we were able to kill one and add a second transaction log file, which allowed other transactions to start completing again.

Something like this:

BEGIN TRANSACTION;

/* Kill session 99 to release any locks/log space it may be holding */

 KILL 99;

/* Add a second log file to DatabaseName on a different drive */

ALTER DATABASE [DatabaseName]

ADD LOG FILE (

NAME = N'DatabaseName_log2'

, FILENAME = N'L:\ Logs\DatabaseName_log2.ldf'

, SIZE = 64MB

, MAXSIZE = 2TB

, FILEGROWTH = 64MB);

 COMMIT TRANSACTION;

After we had the second log file we were able to monitor the progress for CDC and the drive space used by all the transactions recorded. This took a few hours but eventually caught up, and afterwards we emptied and removed the extra transaction log file and resized the original log file to reduce the massive amount of Virtual Log Files (VLFs). We also added a job to alert us in case the transaction log became more than 50% full to avoid another occurrence of this issue.

We were very fortunate, because had we not found a tiny windows to add another log file we would have had no choice but restore from backups. While you’re reading this, make sure your backups are actually ready for restores – check out our free tool, sp_CheckBackup to make sure.


Article by Jeff Iannucci

Jeff loves to help others save time. Whether improving query performance or reducing downtime for maintenance tasks or migrations, he’s not only passionate about discovering ways to save our most valuable resource, but also about sharing what he’s learned. Starting as an accidental DBA in 1998, Jeff has worked extensively with SQL Server database design, administration, and T-SQL development. He appreciates any opportunity to share his knowledge with the community, and has been presenting at user groups and writing blog posts since 2018. He was chosen as an IDERA ACE for 2020, and in 2021 became an author for Pluralsight. When not resolving database issues, he enjoys watching Indycar racing, attending Arizona Diamondbacks and Phoenix Suns games, and cooking Italian food for his wife and four children.

Subscribe for Updates

Name

1 thought on “SQL Server Log File Full at 2 TB Max with CDC: How We Recovered”

  1. BTW – That 2Tb limit is not correctly enforced 🙂

    How do I know?

    Because John Morehouse https://www.johnmorehouse.com/ , Paul Randall and I created one that was multiples of that (I don’t remember the exact size but 10Tb comes to mind) a few years ago

    Also – 2Tb log file —– eeeeeekkkkkk

    Reply

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share This