Share via

Alwayson hadr

Laxmi 61 Reputation points
2022-02-23T18:07:32.587+00:00

Whether we can shrink log file in always on?if yes then how to check logs are committed in standy server before shrinking?

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

Seeya Xi-MSFT 16,756 Reputation points
2022-02-24T06:29:57.663+00:00

Hi @Laxmi ,

First of all, there must be a full backup in Alwayson. Unlike the simple recovery model, the system does not automatic truncate the transaction log after each transaction. For databases with a full or bulk log recovery model, the system truncates the transaction log only after a successful backup of the transaction log.
Some people choose the following: Instance out of availability group - Modify to simple recovery mode - Modify back to full recovery mode - Full backup - Add back to availability group - Restore the secondary copy (note that it is WITH NORECOVERY) - Restart synchronization. I think it is also feasible except it is tedious.
For databases with frequent transaction log growth, you can establish a maintenance plan and back up the transaction log periodically, from a few minutes to an hour.
It is not recommended to shrink the database, because it will still grow after you finish shrinking it.

Best regards,
Seeya


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.

Was this answer helpful?


1 additional answer

Sort by: Most helpful
  1. Erland Sommarskog 134.7K Reputation points MVP Volunteer Moderator
    2022-02-23T22:28:10.023+00:00

    As far as I know, you can, but why would you? Shrinking the transaction log is a very exceptional thing to do.

    Was this answer helpful?


Your answer

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