Not able to shrink logs in Always On

Yashwant Vishwakarma 116 Reputation points
2021-01-04T11:46:22.183+00:00

Hi Folks,

I am facing an issue on one of our Always On SQL Server

Log backups are configured on secondary node

I am trying to shrink the log files on primary server but it is not shrinking.

when i checked log_reuse_wait_desc then it is showing AVAILABILTY_REPLICA, estimated recovery time it is showing approx 27000 seconds and keep on increasing.

Always On is configured with Asynchronous Mode

Any thought how to resolve this issue quickly, This server is hosted on AWS cloud

SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. AmeliaGu-MSFT 14,006 Reputation points Microsoft External Staff
    2021-01-05T07:10:51.987+00:00

    Hi @Yashwant Vishwakarma ,

    when i checked log_reuse_wait_desc then it is showing AVAILABILTY_REPLICA.

    The log_reuse_wait_desc showing "AVAILABILITY_REPLICA" occurs when the logged changes at the primary replica are not yet hardened on the secondary replica, or the primary replica is waiting for a secondary replica to complete the processing of log records for a REDO.
    There are many reasons for this to happen, such as slow network, long running transactions, etc. Please ensure that there are no problems with the network and no long-running transactions on the primary replica.
    You can try to remove the database from AG, shrink log file and re-add it to the AG.
    Please refer to this article which might help.

    Best Regards,
    Amelia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    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. AmeliaGu-MSFT 14,006 Reputation points Microsoft External Staff
    2021-01-07T09:45:48.683+00:00

    Hi YashwantVishwakarma-9317,
    Sorry for delay.
    You can check the following things to troubleshoot this issue:

    • Check if there are any long transactions on the primary replica. This query may help you: USE MASTER
      GO
      SELECT spid,
      PROGRAM_NAME,
      nt_userName,
      loginame,
      DB_NAME(s.dbid) AS DatabaseName,
      CR.TEXT AS Query
      FROM sysprocesses s
      CROSS apply sys.Dm_exec_sql_text(sql_handle) CR
      WHERE open_tran = 1
    • Please check the SQL Server:Database Replica > Redo Bytes Remaining Performance Monitor counter on the secondary replicas. If this counter continues to increase, it means that the secondary replica could not process the log records fast enough for REDO, causing the primary replica to wait and for SQL Server to not be able to truncate the log on the primary replica.
    • You can use the AlwaysOn Dashboard and sys.dm_hadr_database_replica_states dynamic management views to help monitor the log send queue and redo queue. Some key fields are:

    54366-01.jpg

    Best Regards,
    Amelia


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.