Help Center > > Developer Guide> Data Import> Managing Concurrent Write Operations> Concurrent UPDATE in the Same Table

Concurrent UPDATE in the Same Table

Updated at: Mar 13, 2020 GMT+08:00

Transaction T1:

1
2
3
START TRANSACTION;
UPDATE test SET address='test1234' WHERE name='test1';
COMMIT;

Transaction T2:

1
2
3
START TRANSACTION;
UPDATE test SET address='test1234' WHERE name='test2';
COMMIT;

Transaction T3:

1
2
3
START TRANSACTION;
UPDATE test SET address='test1234' WHERE name='test1';
COMMIT;

Scenario 1:

T1 is started but not committed. At the same time, T2 is started. The UPDATE of T1 and then T2 starts, and both of them succeed. This is because UPDATE operations use row-level locks and do not conflict when they update different rows.

Scenario 2:

T1 is started but not committed. At the same time, T3 is started. The UPDATE of T1 and then T3 starts, and the UPDATE of T1 succeeds. The UPDATE of T3 times out. This is because T1 and T3 update the same row, the lock on which is held by the uncommitted T1.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel