3 ms·
Is there a MySQL equivalent for "FOR UPDATE SKIP LOCKED"? That's a feature that I've fallen in love with because it has completely eradicated the need to have a
by majewsky 5y ago
Is there a MySQL equivalent for "FOR UPDATE SKIP LOCKED"? That's a feature that I've fallen in love with because it has completely eradicated the need to have a message queue like RabbitMQ or whatever. For example, for distributing jobs to background workers, I just insert them into a jobs table and have the workers poll for jobs with:
DELETE FROM jobs WHERE id = (
SELECT id FROM jobs FOR UPDATE SKIP LOCKED
) RETURNING *;
Then just commit the respective transaction on success or rollback on failure. Would this look as simple as that in MySQL?
- evanelias 5y agoMySQL 8 supports FOR UPDATE SKIP LOCKED [1], but does not have a RETURNING clause. MariaDB 10.5+ supports a RETURNING clause, and 10.6 now has FOR UPDATE SKIP LOCKED. This is quite new though (10.6 went GA a month ago) so there might be some wrinkles. [1] https://mysqlserverteam.com/mysql-8-0-1-using-skip-locked-and-nowait-to-handle-hot-rows/ https://mysqlserverteam.com/mysql-8-0-1-using-skip-locked-an...