Home » SQL Server Error 1222 lock request time out period exceeded

SQL Server Error 1222 lock request time out period exceeded

sql server DBA 999

SQL Server Error 1222 lock request time out period exceeded

 

Lock request time out period exceeded using SSMS in SQL Server

The error message:

lock request time out period exceeded. (microsoft sql server, error: 1222)

SQL Server Error 1222 lock request time out period exceeded is related to the time out of query due to locking of resources in SQL server.

Lock request time out period exceeded. (.Net SqlClient Data Provider) using SQL Server Management Studio.

Why and How to fix:

 

The error message “Lock request timeout period exceeded Error 1222” indicates that a transaction is holding a lock on the target resource for a longer period than the query could wait for.

This could be caused by a transaction running with a BEGIN TRAN but no ROLLBACK or COMMIT, potentially locking system tables.

To resolve this issue, identify the active transaction details in the SQL Server Management Studio by executing the command “DBCC opentran()”.

If the issue is believed to be caused by a transaction executed through the SSMS, shutting the SSMS may be a solution. This is a slightly drastic step but should usually resolve the problem.

I would like to share with you some details about this issue and how to find and fix it.
1. The first thing is to run a transaction without adding commit transaction, for example:
 begin transaction
 CREATE TABLE TEST (ID INT)
2. Modify the SET LOCK TIMEOUT in SQL Server Management Studio->Tools->Options->Query Execution->SQL Server->Advanced change the SET LOCK TIMEOUT from -1 to 10000 miliseconds.
Lock request time out period exceeded using SSMS

Lock request time out period exceeded using SSMS

SQL Server Error 1222 lock request time out period exceeded

3. Now go to the Object Explorer and try to expand tables and after around 10 seconds you are going to have the error message:

Related Messages are:

  1. how do i fix the lock request time out period exceeded in sql server
  2. lock request time out period exceeded. (microsoft sql server, error: 1222)
  3. sql server lock request time out period exceeded when expanding table
  4. how to fix lock request time out period exceeded
  5. com microsoft sqlserver jdbc sqlserverexception lock request time out period exceeded
  6. lock request time out period exceeded drop table
  7. sql server rebuild index lock request time out period exceeded
  8. dbcc opentran

Why is happening this error?

let’s investigate what is doing SQL Server Management Studio to fill up the list of the tables, using SQL Server Profiler
Lock request time out period exceeded using SSMS

Lock request time out period exceeded using SSMS

Following the instructions,
SSMS specified SET LOCK TIMEOUT 10000 and after it try to execute the query:
SELECT SCHEMA_NAME(tbl.schema_id) AS [Schema], tbl.name AS [Name], tbl.object_id AS [ID] FROM sys.tables AS tbl ORDER BY [Schema] ASC,[Name] ASC As sys.tables
is now blocking by a previous
CREATE TABLE instruction we have to wait to release this blocking.
Finally, after this 10 seconds we are going to receive this error message meanwhile we don’t execute the commit transaction of the execution of CREATE TABLE.
Sometimes, this issue could happen to performance issues.

Now below query can give the list of long running queries..

SELECT
[s_tst].[session_id],
[s_es].[login_name] AS [Login Name],
DB_NAME (s_tdt.database_id) AS [Database],
[s_tdt].[database_transaction_begin_time] AS [Begin Time],
[s_tdt].[database_transaction_log_bytes_used] AS [Log Bytes],
[s_tdt].[database_transaction_log_bytes_reserved] AS [Log Rsvd],
[s_est].text AS [Last T-SQL Text],
[s_eqp].[query_plan] AS [Last Plan]
FROM
sys.dm_tran_database_transactions [s_tdt]
JOIN
sys.dm_tran_session_transactions [s_tst]
ON
[s_tst].[transaction_id] = [s_tdt].[transaction_id]
JOIN
sys.[dm_exec_sessions] [s_es]
ON
[s_es].[session_id] = [s_tst].[session_id]
JOIN
sys.dm_exec_connections [s_ec]
ON
[s_ec].[session_id] = [s_tst].[session_id]
LEFT OUTER JOIN
sys.dm_exec_requests [s_er]
ON
[s_er].[session_id] = [s_tst].[session_id]
CROSS APPLY
sys.dm_exec_sql_text ([s_ec].[most_recent_sql_handle]) AS [s_est]
OUTER APPLY
sys.dm_exec_query_plan ([s_er].[plan_handle]) AS [s_eqp]
where [s_tdt].[database_transaction_begin_time] is not null
ORDER BY
[Begin Time] ASC;

 

Leave a Reply

Your email address will not be published. Required fields are marked *