The transaction log for database is full due to 'REPLICATION'

zoe Ohara 286 Reputation points
2022-04-25T08:33:47.077+00:00

Hi!

I have a SQL 2019 database that is a member of 3 node always on availability group.
It is also the subscriber being populated from a DB2 database.

The log keeps filling up and I am unable to shrink or backup.. I get the message:

The transaction log for database is full due to 'REPLICATION'

The log_reuse_wait_desc is 'REPLICATION'

The disk is not full but the log file is 2.TB (Which I think is the maximum)

It won't allow me to backup, shrink the file or add an additional log file

When I run
SELECT [is_published]
,[is_subscribed]
,[is_cdc_enabled]
FROM sys.databases
WHERE name = 'HDQBPC51MF'

I get

is_published = 1
is_subscribed = 0
is_cdc_enabled = 0

Any idea how I can shrink the log file?

Thanks,

Zoe

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,004 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,656 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. YufeiShao-msft 7,121 Reputation points
    2022-04-26T07:02:33.067+00:00

    Hi @zoe Ohara ,

    Replication is enable in your database, SQL Server will not turncate the transaction log file and this start filling your disks

    The log_reuse_wait_desc is 'REPLICATION'

    This means replication is causing the log not shrinking problem
    you need to make sure that your replicas are in sync, run

    DBCC loginfo  
    

    to see the status of what the database still need to be replicated, when you replication queue is empty, back up the log file and then try shrinking it

    You can reset this by turning the Reader agent off, and run the query on the database for which you want to fix the replication issue:

    EXEC sp_repldone @xactid = NULL, @xact_segno = NULL, @numtrans = 0, @time= 0, @reset = 1  
    

    Make sure all replications as successful and your replication queue will be empty.
    Close the connection where you executed that query and restart SQL Server Agent(or Reader Agent)

    https://dba.stackexchange.com/questions/159202/unable-to-shrink-log-file-due-to-transactional-replication
    https://sqlity.net/en/1846/log-reuse-waits-explained-replication/


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

  2. Olaf Helper 45,106 Reputation points
    2022-04-26T05:21:57.837+00:00

    The transaction log for database is full due to 'REPLICATION'

    Seems replication is broken, you should check it first. I guess this query returns also the same reason:

    select name, log_reuse_wait_desc
    from sys.databases
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.