for the crash. On the one hand, due to the concurrency of multiple users and multi-tasks and the integrity requirements of transactions, when multiple transactions access multiple resources at the same time, if both parties have locked a part of resources but both of them need resources locked by the other party, they will be in an infinite waiting state if they cannot fully obtain the required resources within a limited period of time, this causes deadlocks on resource requirements.On the othe
reasons for the crash. On the one hand, due to the concurrency of multiple users and multi-tasks and the integrity requirements of transactions, when multiple transactions access multiple resources at the same time, if both parties have locked a part of resources but both of them need resources locked by the other party, they will be in an infinite waiting state if they cannot fully obtain the required resources within a limited period of time, this causes deadlocks on resource requirements.On
correct, should every request error Ah, now is dozens of times only one or two times the error, certainly not this reason.Search on the internet for half a day, no fruit, so put the code on the server to simulate concurrent testing, or there will be one or two times the error, but the report of the error is very clear# # # Error QueryingDatabase. Cause:com.microsoft.sqlserver.jdbc.SQLServerException: Transaction (Process ID +) is deadlocked with anot
Find out the source of deadlock and blocking for SQL Server--Find out the source of SQL Server deadlock and blocking
Copy Code code as follows:
Use master
Go
declare @spid int, @bl int
DECLARE S_cur CURSOR f
An exception was encountered today when doing SQL Concurrency update: (Code below)// Parallel class can produce concurrent operations (i.e. multithreading) Parallel.ForEach (topics, topic ={ //DBHelper is a encapsulated database operation class, the following line of code executes the UPDATE statement "topicid=" + topic. TOPICID);});This problem occurs because, in SQL
deadlock
View deadlocks through profiler
Another method is to enable profiler to capture the deadlock information captured by Profiler, which is more intuitive, as shown in profiler setting 6.
Figure 6. settings of the deadlock graph in profiler
Figure 7 shows the deadlock.
Figure 7.
, when a deadlock occurs, you can see the relevant record from the log, as shown in 5.Figure 5: Post-deadlock recordCheck the look dead lock through the profiler.Another method is to open the profiler to capture, the profiler captures the deadlock information content is more intuitive, profiler settings 6.Figure 6. Setting of lock diagram in ProfilerThe captured
. Turn on 1222 This trace Flag for all session In addition to code 1, you can also –t1222 the add-on parameter before starting the SQL Server instance. This is no longer a detail. At this point, when a deadlock occurs, you can see the relevant record from the log, as shown in 5. Figure 5: Post-deadlock record Check th
Note: The transaction (process ID 56) and another process are deadlocked. | the communication buffer zone resource has been selected as the deadlock victim ., Note as dead
An exception occurred during SQL concurrent UPDATE today: (the Code is as follows)
// Parallel class can generate concurrent operations (that is, multithreading) Parallel. forEach (topics, to
point, when a deadlock occurs, you can see the relevant record from the log, as shown in 5.Figure 5: Post-deadlock recordCheck the look dead lock through the profiler.Another method is to open the profiler to capture, the profiler captures the deadlock information content is more intuitive, profiler settings 6.Figure 6. Setting of lock diagram in ProfilerThe cap
exceeded. (3). There is a lock monitor thread inside SQL server that performs a deadlock check that identifies the resource that the thread is waiting for when the lock monitor initiates a deadlock search for a particular thread, then locates the owner of a specific resource and recursively resumes the
two queries hold resources and do not , which constitutes a deadlock.(4). Workarounda). SQL Server automatically selects a SQL as a deadlock victim : After running the two queries above, we will find that one
This article will introduce several major steps for SQL Server Profiler to analyze deadlocks. This is also to help you better manage your databases.
In two or more SQL Server processes, a deadlock occurs when each process locks the resources that other processes attempt to l
SQL server that performs a deadlock check that identifies the resource that the thread is waiting for when the lock monitor initiates a deadlock search for a particular thread, then locates the owner of a specific resource and recursively resumes the deadlock search for tho
Will return an error. When the timeout_period value is 0, the message is returned when the lock is encountered. Set lock request timeout, break the deadlock
Two necessary conditions (request and retention conditions ).
Server: Message 1222, level 16, status 50, Row 1The lock request timeout period has been exceeded.
(3). There is a lock Monitor thread in SQL
';SELECT * FROM Lock2Rollback Tran;-- Query 2Begin TranUpdate Lock2 Set C1 = C1 + 1;WaitFor Delay '00: 01: 00 ';SELECT * FROM Lock1Rollback Tran; The preceding SQL statement WaitFor Delay '00: 01: 00' is used to wait for 1 minute to check the lock.SolutionA). SQL Server automatically selects an SQL
occur on the same resource:By the end of this step, we can only confirm that the deadlock has occurred, and that it has not been able to obtain a specific deadlock statement and resource information on the same resource, and the problem cannot be solved fundamentally. 3) in order to check the look dead lock information, the database engine provides a monitoring tool: Trace identity (1222). Open this trace
This article is reproduced articles, the description is very good, has not been verified.I've recently encountered a deadlock problem that seems strange and interesting to analyze. This deadlock seems to be hard to understand. In the analysis process, a lot of typical methods of parsing SQL Server
Lockedresource,db_name (one) as DBName;--------------------------------------------------------------Lockedresource DBName--------------------------------------------------------------Tb_te_sizeinformation JybgdbExecute the following script to get the SQL script that is executing the session of the lock resource:DBCC InputBuffer (54);--------------------------------------------------------------EventType Parameters EventInfo--------------------------
cursor local for select distinct hostname from # TBOpen TBFetch next from TB into @ hostnameWhile @ fetch_status = 0BeginSet @ SQL = 'ping' + @ hostname + '-a-n 1-l 1'Insert # IP (a) exec master .. xp_mongoshell @ SQLUpdate # IP Set hostname = @ hostname where hostname is nullFetch next from TB into @ hostnameEndUpdate # TB set net_ip = left (A, patindex ('%: %', a)-1)From # TB a inner join (Select hostname, A = substring (A, patindex ('Ping statisti
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.