February 2018
Intermediate to advanced
510 pages
16h 10m
English
When rows are locked by other transactions that you are trying to access, then you need to wait for that transaction to release the lock on the same row so that you can access it accordingly. To avoid waiting for the other transaction, InnoDB has added support of the NOWAIT and SKIP LOCKED options. NOWAIT will return immediately with an error in case the requested row is locked rather than going into the waiting mode, and SKIP LOCKED will skip the locked row and never wait to acquire the row lock. Hence, SKIP LOCKED will not consider the locked row in the resulting set:
SELECT * FROM table1 WHERE id = 5 FOR UPDATE NOWAIT;SELECT * FROM table1 FOR UPDATE SKIP LOCKED;
Read now
Unlock full access