From fe32d8d47bf9e69c420191ea9170babd31764565 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 21 Apr 2023 11:13:05 +0300 Subject: [PATCH] job no table locking param --- application/Espo/Core/Job/ConfigDataProvider.php | 5 +++++ application/Espo/Core/Job/QueueProcessor.php | 11 ++++++++--- application/Espo/Resources/defaults/systemConfig.php | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/application/Espo/Core/Job/ConfigDataProvider.php b/application/Espo/Core/Job/ConfigDataProvider.php index 5a55c84879..e85246f57b 100644 --- a/application/Espo/Core/Job/ConfigDataProvider.php +++ b/application/Espo/Core/Job/ConfigDataProvider.php @@ -49,4 +49,9 @@ class ConfigDataProvider { return (int) $this->config->get('cronMinInterval', 0); } + + public function noTableLocking(): bool + { + return (bool) $this->config->get('jobNoTableLocking'); + } } diff --git a/application/Espo/Core/Job/QueueProcessor.php b/application/Espo/Core/Job/QueueProcessor.php index 0c26da18d1..c2df6c5f0e 100644 --- a/application/Espo/Core/Job/QueueProcessor.php +++ b/application/Espo/Core/Job/QueueProcessor.php @@ -39,12 +39,17 @@ use Spatie\Async\Pool as AsyncPool; class QueueProcessor { + private bool $noTableLocking; + public function __construct( private QueueUtil $queueUtil, private JobRunner $jobRunner, private AsyncPoolFactory $asyncPoolFactory, - private EntityManager $entityManager - ) {} + private EntityManager $entityManager, + ConfigDataProvider $configDataProvider + ) { + $this->noTableLocking = $configDataProvider->noTableLocking(); + } public function process(Params $params): void { @@ -68,7 +73,7 @@ class QueueProcessor private function processJob(Params $params, JobEntity $job, ?AsyncPool $pool = null): void { $noLock = $params->noLock(); - $lockTable = $job->getScheduledJobId() && !$noLock; + $lockTable = $job->getScheduledJobId() && !$noLock && !$this->noTableLocking; if ($lockTable) { // MySQL doesn't allow to lock non-existent rows. We resort to locking an entire table. diff --git a/application/Espo/Resources/defaults/systemConfig.php b/application/Espo/Resources/defaults/systemConfig.php index fadc26b377..46589cd844 100644 --- a/application/Espo/Resources/defaults/systemConfig.php +++ b/application/Espo/Resources/defaults/systemConfig.php @@ -101,6 +101,7 @@ return [ 'authLogDisabled', 'authApiUserLogDisabled', 'ipAddressServerParam', + 'jobNoTableLocking', ], 'adminItems' => [ 'devMode',