Causes and resolutions of deadlock in SQL Server 2006-07-18 05:12:10Category: SQL ServerIn fact, the deepest cause of all deadlocks is one: resource competitionPerformance One:A User A accesses table A (locks up table A), then accesses table B, another user B accesses table B (locked table B), and then attempts to access table A, when user a because User B has lo
I wrote a stored procedure the other day and used transactions in the stored procedure.CodeComment out to debug and find the error. Suddenly, a table is locked. It turns out that the code for creating the transaction has forgotten to comment out. Solution to table lock in this article.There are many other scenarios that cause a deadlock in the Table. Unlocking is actually very simple. Here is an example:
1. First create a test table: Create Table Tes
I wrote a stored procedure the other day and used transactions in the stored procedure.CodeComment out to debug and find the error. Suddenly, a table is locked. It turns out that the code for creating the transaction has forgotten to comment out. Solution to table lock in this article.
In fact, not only will the table be locked as described above, but there are also many scenarios that will cause a deadlock in the Table. Unlocking is actually very si
creating a transaction. Solution to table lock in this article. In fact, not only will the table be locked as described above, but there are also many scenarios that cause a deadlock in the Table. Unlocking is actually very simple. The following example is used to explain: 1. first create a table for testing:
Create table Test (tid int identity (1, 1 ))
2. Execute the following SQL statement to lock
Tags: io os sp data on CTI Code BS ASRecently in a large-scale project, because data design uses a discrete database design to facilitate requirements change and user-defined process elements, because the user-defined features, data integrity by code constraints become less realistic, can only rely on the relationship between the table constraints, resulting in data operations often produce X (exclusive) lock, Severely affect data performance.The most straightforward solution to a database
Pl/SQL deadlock: record is locked by another user due to a problem, I found a solution in a blog. After a try, I found the solution feasible! Www.2cto.com is afraid of poor memory! Also as your own search direction 1. PL/SQL query locks: select t2.username, t2.sid, t2.serial #, t2.logon _ timefrom v $ locked_object t1, v $ session t2where t1.session _ id = t2.sid
Mysql uses the kill command to solve the deadlock problem (killing an SQL statement being executed)
When using mysql to run certain statements, the deadlock is caused by a large amount of data, which is not reflected. At this time, you need to kill a query statement that is consuming resources. The syntax format of the kill command is as follows: Mysql uses the
@intCounter @intCountProperties
begin
--take the first record
Select @spid =spid@bl =BL from#tmp_lock_whowhereId= @intCounter
begin
if @spid =0
Select 'causing the database deadlock is:'+ CAST(@bl as VARCHAR(Ten))+ 'process number, which executes the following SQL syntax'
Else
Select 'process number spid:'+ CAST(@spid as VARCHAR(T
Release date: 2008.02.01 Source: CCID Author: Alice
If a deadlock occurs, how can we check which SQL statement or stored procedure is causing the deadlock? In this case, we can use the following stored procedure to detect the process and SQL statements that cause the
If @ error -- find the number of records in the temporary table select @ intcountproperties = count (*), @ intcounter = 1 from # tmp_lock_who If @ error If @ intcountproperties = 0 select 'no blocking and deadlock information' as message
-- Start of LoopWhile @ intcounter Begin-- Retrieve the first recordSelect @ spid = spid, @ BL = blFrom # tmp_lock_who where id = @ intcounterBeginIf @ spid = 0Select '+ Cast (@ BL as varchar (10) +' causes
In fact, not only the situation described above will lock the table, there are many kinds of scenes that will put the table to lock the life and death, unlock is actually very simple, the following an example to explain:
1 Create a test table first:
Copy Code code as follows:
CREATE TABLE Test
(
TID INT IDENTITY (1,1)
)
2 Execute the following SQL statement to lock the table:
Copy Code code as follows:
SELECT * from Test
Tags: DDR amp ESC sel EPO system datetime Order AddressViewing with extended events for dynamic viewsSELECT
xed.value (' @timestamp ', ' datetime ') as Creation_date,
xed.query ('. ') As Extend_event
from
(
SELECT CAST ([Target_data] as XML) as Target_data
from sys.dm_xe_session_ Targets as XT
sys.dm_xe_sessions as xs on
xs.address = xt.event_session_address
WHERE Xs.name = N ' system_health ' and
xt.target_name = n ' ring_buffer '
) as Xml
SYS. sysprocesses is an important system view. It is mainly used to locate and solve SQL Server blocking and deadlock.
Msdn: contains information about processes running on an SQL server instance. These processes can be client processes or system processes.
Main fields in the View:
1. spid: SQL servr
A deadlock occurs when the data table is manipulated in PL/SQL and is unresponsive for a long time, and when editing data in a table, there is a "record is locked by another user".Below, a brief description of the solution:Step1.pl/sql View Lock:Select T2.username, T2.sid, T2.serial#,t2.logon_timeFrom V$locked_object t1,v$session T2where t1.session_id = T2.sid[Or
Label:Write a stored procedure a few days ago, the stored procedure used a transaction, and then I put some code comments out to debug the wrong, suddenly found a table is locked, the original is the code to create a transaction forget to comment out. This table locks the workaround. In fact, not only the situation described above will lock the table, there are many kinds of scenes will make the table life and Death lock, unlocking is actually very simple, the following with an example to explai
Tags: Profiler deadlock deadlock Trace transactionSQL Server Profiler-Debug DeadlockTracking generic exceptions is simple, but dealing with deadlocks is difficult, with a deadlock message number of 1205 and a severity of 13. The only suggestion that the server can "rerun the transaction" is that it cannot get enough data from the server to help determine what exa
In fact, not only will the table be locked as described above, but there are also many scenarios that will cause a deadlock in the Table. Unlocking is actually very simple. The following example is used to explain:1. First create a test table:Copy codeThe Code is as follows:Create table Test(Tid int identity (1, 1)) 2. Execute the following SQL statement to lock the table:Copy codeThe Code is as follows:SEL
I wrote a stored procedure the other day and used transactions in the stored procedure. Later I commented out some code for debugging and found that a table was locked, I forgot to comment out the code for creating a transaction. Solution to table lock in this article.
I wrote a stored procedure the other day and used transactions in the stored procedure. Later I commented out some code for debugging and found that a table was locked, I forgot to comment out the code for creating a transaction.
Select T.username,count (*) from v$session T GROUP by T.username
//Find the sql_id value that a user is executing based on the user group session Select
* From V$session t where T.username = ' BUDGET ' and t.sql_id are NOT NULL
//lookup corresponding SQL_ID's corresponding SQL statement
select M.sql_text from V$session T, V$sqlarea m where t.username = ' BUDGET ' and t.sql_id = m.sql_id
//
SELECT * from V$sqlarea t where T. sql_id = ' G92sy7kwt6mrq '
1. First we need to determine which user is locked in which table.
--Query Locked table
Select request_session_id spid,object_name (resource_associated_entity_id) tablename
A table that contains the SPID and tablename columns is returned after the query.
Where the SPID is the process name and TableName is the table name.
2. Knowing which process has locked the table, you need to find the host that locked the table through the process.
--Query host name
exec sp_who2 ' xxx '
xxx
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.