The transaction log for database ' xx ' is full,error:9002, severity:17, State:2

Source: Internet
Author: User

Check the database log, with the following error message:

error:9002, Severity:17, State:4. The
transaction log for database ' sharedservices1_search_db ' are full. To find out why spaces in the log cannot be reused, and the Log_reuse_wait_desc column in sys.databases

To view the usage of the current log:

The log is not fully full, but it has taken up 79% of the 70GB log file, and more than 50 GB, and it is not normal for the individual to feel this. Individuals have read the "SQL Server 2012 Implementation and Management Guide", in the log this piece has a description:

Because of application design problems, some connections may leave a transaction in SQL Server instead of submitting it in a timely manner, and SQL Server does not interfere with the user's behavior. As long as this connection does not exit, the transaction will always exist until the client submits or rolls back voluntarily. All of the logging that starts at that point in time for this transaction is reserved by SQL Server (no use for log backups).

so the existence of long affairs is the most dubious clue.
View the log_reuse_wait and LOG_REUSE_WAIT_DESC values of the database ' sharedservices1_search_db ' in the system view sys.databases:

Here you can see the log_reuse_wait_desc value of ' active_transaction '
That is, the log is waiting for the transaction checkpoint. It is further proved that long transactions cause large transaction logs to be caused by an extra long office.
For a description of the sys.databases view See (https://msdn.microsoft.com/zh-cn/library/ms178534.aspx+%20+%22%E5%AE%98%E6%96%B9%E8%AF% B4%E6%98%8E%22)

To view long transactions:

currentdate
2015-04-08 14:47:42.430

You can see that a long transaction is running, and it has been running for nearly 90 minutes.
View transaction Related information:

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

View transaction specific content according to session_id:

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 ................... ...

You can also look at the current state of the transaction by 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 no  Tstarted ' when 
2 Then ' active ' if 
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 "when 
0 Then ' been rolled back '" 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

Identify the statement, you can find a developer together to see why.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.