| |

VerySource

 Forgot password?
 Register
Search
View: 800|Reply: 3

May I ask a question about deadlock

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-3 17:00:01
| Show all posts |Read mode
May I ask: If a transaction takes too long from start to end, will other processes generate interlocks when updating or inserting this table? Is there a timeout when selecting this table?
Another question is whether the deadlock is caused by the transaction?
Reply

Use magic Report

0

Threads

29

Posts

16.00

Credits

Newbie

Rank: 1

Credits
16.00

 Dominican Republic

Post time: 2020-1-3 23:09:01
| Show all posts
Look at the form of your lock. Is it a table lock or a row lock.
Reply

Use magic Report

0

Threads

41

Posts

13.00

Credits

Newbie

Rank: 1

Credits
13.00

 China

Post time: 2020-1-3 23:39:01
| Show all posts
Let me give you an example of a deadlock:

-- test environment
USE tempdb
GO
CREATE TABLE t1 (id int)
INSERT t1 VALUES (1)
CREATE TABLE t2 (id int)
INSERT t2 VALUES (2)
GO

-Execute the following statement in query window 1
USE tempdb
GO
BEGIN TRAN
SELECT * FROM t1 WITH (TABLOCKX)
WAITFOR DELAY '00: 00: 10 '
UPDATE t2 SET id = 1
COMMIT TRAN
GO

-Execute the following statement in query window 2
USE tempdb
GO
BEGIN TRAN
SELECT * FROM t2 WITH (TABLOCKX)
WAITFOR DELAY '00: 00: 10 '
UPDATE t1 SET id = 1
COMMIT TRAN
GO


-Delete the test environment after the test is complete
DROP TABLE t1, t2
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-3 23:57:01
| Show all posts
You should understand what is deadlock and what is blocking? !!

Deadlocks are bound to block, but blocking is not necessarily a deadlock!
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list