Understanding Transaction Log Truncation in SQL Server 2022

Roberto Limongello 5 Reputation points
2025-01-21T08:37:26.9166667+00:00

In an Azure SQL Server 2022 environment with multiple databases configured with FULL recovery mode, hourly log backups are taken, and full backups occur nightly.

According to the documentation, the expectation is that the log space usage should decrease to 0 or close to it after each log backup. However, observations show that the log space continues to grow over several days. While there are instances where the log is truncated, the specific circumstances leading to this behavior are unclear.

Standard troubleshooting steps have been taken, including monitoring the log_wait_reuse flag (which remains at NOTHING) and checking the recovery model interval (currently at 0), among other diagnostics.

What could be missing in this scenario?

SQL Server Other
{count} votes

2 answers

Sort by: Most helpful
  1. Roberto Limongello 5 Reputation points
    2025-01-31T16:08:00.9066667+00:00

    Follow up:

    I opened a case to MS and after some exchanges I figure it out.

    I was assuming for some reason that the VLF are all created equals in size. This is not always true apparently. In one case in particular I had 2/6 VLF occupying the 99% of the LDF meaning that the before the VLF inactivation would occur the usage would peak to 50% or more. This was more evident of course in small sized LDF.

    1 person found this answer helpful.

  2. RahulRandive 10,486 Reputation points Volunteer Moderator
    2025-01-22T21:37:47.89+00:00

    Hi @Roberto Limongello

    If the log space usage continues to grow despite regular log backups, it could be due to several factors:

    1. In-Memory OLTP Checkpoints: If the databases have the In-Memory OLTP feature enabled, the transaction log might be waiting for an In-Memory OLTP checkpoint to occur.
    2. Active Transactions: Long-running or uncommitted transactions can prevent log truncation.
    3. Replication or CDC: If CDC or replication is enabled, it might be causing the log to grow.
    4. Database Mirroring or Availability Groups: If the database is part of a mirroring setup or an availability group, synchronization issues might prevent log truncation.

    Thank You!


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.