diff --git a/app/Console/Commands/SendoutDispatcher.php b/app/Console/Commands/SendoutDispatcher.php index fa231f10..55c77444 100644 --- a/app/Console/Commands/SendoutDispatcher.php +++ b/app/Console/Commands/SendoutDispatcher.php @@ -245,0 +246,4 @@ class SendoutDispatcher extends Command + // The fully qualified statistics table is on the same server. Use + // the company/job transaction so its FK check cannot wait on our + // own company lock, and queue/stat/job changes roll back together. + $stat->setConnection($job->getConnectionName()); @@ -319 +323 @@ class SendoutDispatcher extends Command - $prio = $stat->sendout->stats()->count(); + $prio = $stat->newQuery()->where('sendout_id', $job->sendout_id)->count(); @@ -328 +332 @@ class SendoutDispatcher extends Command - $prio = $stat->sendout->stats()->count(); + $prio = $stat->newQuery()->where('sendout_id', $job->sendout_id)->count();