Issue:

Log has grown to be very large and unable to trunk log file even after database and transaction log backup. Get the following error message when trying to truncate log.

The log was not truncated because records at the beginning of the log are pending replication or Change Data Capture. Ensure the Log Reader Agent or capture job is running or use sp_repldone to mark transactions as distributed or captured.

Fix:

Make sure the Log Reader Agent is running.

Go to Replication -> Local Publication -> View Log Agent Reader Status -> Start

Afterwards, you should be able to shrink the transaction log file.

BACKUP LOG [MyDB01] TO DISK='C:\Backup\MyDB01_Log_.trn' WITH NO_CHECKSUM, CONTINUE_AFTER_ERROR

DBCC SHRINKFILE (MyDB01_log, EMPTYFILE);

Sources:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/c96f3cb4-5f4e-49a4-a84a-6e2cd46915a3/quotthe-log-was-not-truncated-because-records-at-the-beginning-of-the-log-are-pending?forum=sqlreplication

Last modified: November 15, 2021

Author

Comments

Write a Reply or Comment