MySQL Forums
Forum List  »  Newbie

Re: Best MySQL schema for storing image processing jobs?
Posted by: Herrick Peterson
Date: August 25, 2026 01:25AM

Good call, yes SKIP LOCKED is basically essential once you've got more than one worker polling the same table. Without it you get workers either blocking on each other or double-picking the same job in a race condition, both annoying in different ways.

One thing to pair with it: wrap the select+status update in a single transaction, something like:

sql
START TRANSACTION;
SELECT id FROM jobs WHERE status = 'queued'
ORDER BY created_at LIMIT 1 FOR UPDATE SKIP LOCKED;
UPDATE jobs SET status = 'processing', worker_id = ? WHERE id = ?;
COMMIT;

That way the lock only holds for the tiny window of claiming the job, not the actual processing time. Also worth adding a locked_at timestamp alongside worker_id, if a worker crashes mid-job you can have a cleanup process requeue anything stuck in processing past some timeout, otherwise those jobs just sit there forever with no worker coming back for them.

Herrick
DevOps Engineer
Accuweb.cloud

Options: ReplyQuote


Subject
Written By
Posted
Re: Best MySQL schema for storing image processing jobs?
August 25, 2026 01:25AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.