Replies: 3 comments
-
If I remember correctly, I pushed some jobs initially in a loop but also had a cron running that keeps dispatching jobs. That way when the workers run, we will have inserts, updates, and deletions at the same time Without the SKIP LOCKED flag I started seeing deadlocks almost as soon as workers started. With the flag. I was able to process all jobs without any deadlocks. |
Beta Was this translation helpful? Give feedback.
-
Without any modification to the SqlServer database queue driver, I can't get any deadlocks to surface. 50 workers and a while loop endlessly creating jobs got up to about 200k jobs before I stopped the worker). Everything seems to be going smoothly. So, while I guess theoretically there could be an issue, it seems that this Just Works™ to a pretty good degree out of the box for SqlServer.
|
Beta Was this translation helpful? Give feedback.
-
OK, I've tested with the default locking and with the usage of So, no modification is needed from my point of view. I tested with a job that runs thisin the
That table migration: Schema::create('HS_Jobs_Usage', function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('job_id');
}); Query to see if one is run more than once: select job_id, count(job_id) as times_ran
from HS_Jobs_Usage
group by job_id
order by times_ran desc; No jobs were run more than once and I never once got a query exception about deadlock timeouts. 50 works, ~200k jobs or so (via a while loop that continued to add jobs to the queue). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
It looks like SqlServer's equivalent to
SKIP LOCKED
isREADPAST
- usecmd-f
and search forreadpast
on that page (and there's more explanation on it here).READPAST
only works on the default, usual isolation level. However, the use of->lock()
in Laravel for SqlServer adds theHOLDLOCK
locking hint, which appears to not compatible with the use ofREADPAST
.Due to how the SqlServer grammar works, it looks like we can successfully lock the
jobs
table in SqlServer using something like:To get that locking string, we can change the implementation of
getLockForPopping
to this:However I could use help testing this out.
@themsaid do you have a setup around still to create all the jobs and workers you used to test the original implementation? If not, I can try to set something up as I have Windows servers with SqlServer available to use in our AWS account.
Beta Was this translation helpful? Give feedback.
All reactions