Deadlock problem caused by locking sequence

in order to prevent deadlocks, I locked my program sequentially. Such as the order of oa--as-aa. But since I found that the data did not exist when I got the OA, I first new, and then lock it. The result is the new oa- lock, the oa-new as- lock, the as-new aa- lock, the aa lock. But if it goes on like this, there will be a deadlock. What"s the reason? (oa and as locks use exclusive locks, while aa locks use shared locks)

I do this by adding MySQL row-level locks, for update and in share mode, without locking to the same variable.

Apr.18,2021

is the lock nested? Is it locked to the same variable? Is
deadlocked in the second step?

Menu