
Introduction / Issue
During routine operations, SQL Server encountered a critical issue where TempDB’s transaction log became full due to an active transaction. This led to application timeouts, inability to run reports, and even prevented normal connections to SQL Server through SSMS. Essentially, the server entered a near-lockdown state where no new transactions could proceed.
Why We Need to Do / Cause of the Issue
TempDB is a vital system database used for temporary storage of sorts, joins, row versioning, and internal database operations.
The transaction log for TempDB can become full in scenarios such as:
- A long-running active transaction holding space in the log.
- Improper initial sizing or auto-growth settings of the TempDB log file.
- Lack of monitoring on TempDB space usage.
When the log is full, SQL Server cannot allocate new space for ongoing transactions. The immediate impact is that business applications experience downtime, reporting queries fail, and administrators cannot even connect normally to the instance to troubleshoot.
How Do We Solve
To resolve the issue in real-time, the following steps were performed:
- Connect using Dedicated Admin Connection (DAC):
Since SSMS could not connect normally, we used SQLCMD with the -A flag to establish a DAC connection:
SQLCMD -S Servername\Instancename -E -A
- Identify the Active Transaction:
Inside DAC, we ran:
DBCC OPENTRAN(‘tempdb’);
This identified the SPID holding the active transaction.
- Terminate the Blocking Session:
KILL <SPID>;
This freed up TempDB log space immediately and restored normal operations.
- Verify for Leftover Transactions:
DBCC OPENTRAN(‘tempdb’);
Confirmed that no active transactions remained.
- Optional Log File Shrink (Emergency Use):
If the TempDB log file had grown unusually large during the incident, it was shrunk once:
DBCC SHRINKFILE (templog, 500);
(Note: Repeated shrinking is discouraged for performance reasons.)
- Restart SQL Service (Last Resort):
If the issue persisted, TempDB could be recreated by restarting the SQL Server instance. - Preventive Measures:
- Pre-sized TempDB log file with proper growth increments:
ALTER DATABASE tempdb MODIFY FILE (NAME = templog, SIZE = 4GB, FILEGROWTH = 512MB);
- Set up monitoring using sp_spaceused and long-running transaction checks.
Conclusion
The TempDB transaction log full issue was effectively resolved by connecting through DAC, identifying and terminating the blocking session, and applying preventive configuration changes. This restored SQL Server availability, minimized downtime, and ensured stable performance. By implementing proper TempDB sizing and monitoring strategies, we prevented recurrence of the same issue and provided a unique, practical resolution to a potentially high-impact outage.