The transaction log for database 'xx' is full,Error: 9002, Severity: 17, State: 2
2015-04-08 15:17
561 查看
检查数据库日志,有如下报错信息:
查看当前日志的使用情况:
这里日志并没有完全满,但已经占用70GB日志文件的79%,也有50多GB了,个人感觉这是不正常的。个人曾经读过《SQL Server 2012实施与管理实战指南》,在日志这一块有这么一段描述:
所以长事务的存在是最可疑的线索。
在系统视图sys.databases中查看数据库‘SharedServices1_Search_DB’的log_reuse_wait及log_reuse_wait_desc 值:
这里可以看到log_reuse_wait_desc值为‘ACTIVE_TRANSACTION’
也就是说日志正在等待transaction的检查点。这里进一步证明了是长事务导致了超大的事务日志是由超长事务所导致的。
关于sys.databases视图的描述参见(https://msdn.microsoft.com/zh-cn/library/ms178534.aspx+%20+%22%E5%AE%98%E6%96%B9%E8%AF%B4%E6%98%8E%22)
查看长事务:
可以看到果然有长事务在运行,而且已经运行近90分钟了。
查看transaction相关信息:
根据session_id查看transaction具体内容:
也可以通过transaction_id看一下这个事务目前的状态:
确定出来语句了,就可以找开发人员一起看看是为什么了。
Error: 9002, Severity: 17, State: 4. The transaction log for database 'SharedServices1_Search_DB' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases
查看当前日志的使用情况:
这里日志并没有完全满,但已经占用70GB日志文件的79%,也有50多GB了,个人感觉这是不正常的。个人曾经读过《SQL Server 2012实施与管理实战指南》,在日志这一块有这么一段描述:
由于应用程序设计问题,有些连接可能会遗留一个事务在SQL Server里面,而不是及时提交它,SQL Server是不会干预用户的这种行为的。只要这个连接不退出,这个事务会永远存在,直到客户端主动提交或者回滚。从这个事务开启的那个时间点开始的所有日志记录,SQL Server都会保留(做过日志备份也没有用)。
所以长事务的存在是最可疑的线索。
在系统视图sys.databases中查看数据库‘SharedServices1_Search_DB’的log_reuse_wait及log_reuse_wait_desc 值:
这里可以看到log_reuse_wait_desc值为‘ACTIVE_TRANSACTION’
也就是说日志正在等待transaction的检查点。这里进一步证明了是长事务导致了超大的事务日志是由超长事务所导致的。
关于sys.databases视图的描述参见(https://msdn.microsoft.com/zh-cn/library/ms178534.aspx+%20+%22%E5%AE%98%E6%96%B9%E8%AF%B4%E6%98%8E%22)
查看长事务:
currentdate 2015-04-08 14:47:42.430
可以看到果然有长事务在运行,而且已经运行近90分钟了。
查看transaction相关信息:
select session_id,transaction_id,is_user_transaction,is_local from sys.dm_tran_session_transactions where is_user_transaction=1 session_id transaction_id is_user_transaction is_local 1566 3452140915 1 1
根据session_id查看transaction具体内容:
select s.text from sys.dm_exec_connections c cross apply sys.dm_exec_sql_text(c.most_recent_sql_Handle) s where session_id=1566 text CREATE PROCEDURE dbo.proc_MSS_Crawl ..............................
也可以通过transaction_id看一下这个事务目前的状态:
select transaction_begin_time, case transaction_type when 1 then 'Read/Write transaction' when 2 then 'Read-Only transaction' when 3 then 'System transaction' when 4 then 'Distributed transaction' end tran_Type, case transaction_state when 0 then 'not been comoletely initaialiaed yet' when 1 then 'initaialiaed but ha notstarted' when 2 then 'active' when 3 then 'ended (read-only transaction)' when 4 then 'commit initiated for distributed transaction' when 5 then 'transaction prepared and waiting resolution' when 6 then 'commited' when 7 then 'being rolled back' when 0 then 'been rolled back' end transaction_state from sys.dm_tran_active_transactions where transaction_ID=3452140915 transaction_begin_time tran_Type transaction_state 2015-04-08 13:13:52.040 Read/Write transaction active
确定出来语句了,就可以找开发人员一起看看是为什么了。
相关文章推荐
- The transaction log for database 'NJ_Address' is full. To find out why space in the log cannot be
- Error: 9001, Severity: 21, State: 5 The log for database 'xxxx' is not available
- Msg 9002 The transaction log for database '' is full
- DB2 “The transaction log for the database is full” 存在的问题及解决方案
- the transaction log for database *** is full 数据库日志已满
- [Error Fix] The transaction log for database 'DATABASENAME' is full
- DB2 “The transaction log for the database is full” 问题及解决办法
- Can't allocate space for object 'syslogs' in database 'ge' because 'logsegment' segment is full/has no free extents. If you ran
- 'Operation is not valid due to the current state of the object' error during postback
- ASE Can't allocate space for object 'syslogs' in database 'WEN' because 'logsegment' segment is full
- The table 'pre_common_session' is full, Error_code: 1114解决办法
- Rails 4 - Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded
- Msg 9002 The transaction log for database '' is full
- Error 3724:Cannot drop the table 'object_name' because it is being used for replication.
- '4.294967295E9' in column '7' is outside valid range for the datatype INTEGER.
- sybase Space available in the log segment has fallen critically low in database 'tempdb'.
- LGWR Is Generating Trace file with 'Warning Log Write Time 540ms, Size 5444kb' In 10.2.0.4 Database
- VS2010 + Sql Server Express 2008 R2 如何安装(兼谈错误:The database 'XXX' cannot be opened because it is version 661. This server support
- ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'
- [mysql_error]: Access denied for user 'root'@'%' to database 'image' 错误解决