Replication:The transaction log for database 'tempdb' is full due to 'ACTIVE_TRANSACTION'

今天早上,Dev跟我说,执行query statement时出现一个error,detail info是:

The transaction log for database 'tempdb' is full due to 'ACTIVE_TRANSACTION'

错误信息提示:由于活动事务太长,使得 tempdb 的 transaction log file 空间用尽。

一般情况下,由于tempdb 的 Recovery Mode是 simple,日志文件会自动截断和重用,如果活动事务太长,或短时间内事务日志太多,导致事务日志不能及时截断和重用,会出现log file 空间不足的问题。检查tempdb的日志file的设置:最大值,自动增长和Disk 剩余可用空间,保证 tempdb的 log file 有足够的Disk空间。

如果不是日志File设置的问题,那可能是tempdb的数据文件(mdf 或ndf)空间不足。查看Sql server的ErrorLog,发现错误信息:

"Could not allocate space for object 'dbo.TempTable_xxxx' in database 'db_yyyy' because the 'PRIMARY' filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup."

解决方案:

为tempdb 增加 File 或增加现有file的最大值,建议将 tempdb 的 files 存放在不同的Disk上,并且 files 的数量接近于或等于 CPU 数量,这样能够减少 PageLatch 和 PageIOLatch 等待。

参考文档:

Sql Server Error Messages : The transaction log for database ‘tempdb’ is full due to ‘ACTIVE_TRANSACTION’

原文地址:https://www.cnblogs.com/ljhdo/p/5127022.html