From ddd16bc3b14b7a7a511d00b7632c8adf65b16be2 Mon Sep 17 00:00:00 2001 From: Auto-Claude Orchestrator Date: Tue, 24 Mar 2026 07:30:52 +0000 Subject: [PATCH] =?utf8?q?feat(task-JIRA-ERP-33-20260324070448):=20=D0=A1?= =?utf8?q?=D0=B1=D0=BE=D1=80=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20?= =?utf8?q?=D0=BF=D0=BE=20=D0=BE=D1=81=D1=82=D0=B0=D1=82=D0=BA=D0=B0=D0=BC?= =?utf8?q?=20=D0=BD=D0=B0=20=D0=B4=D0=B5=D0=BD=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/StockHistoryService.php | 8 +++++++- erp24/tests/unit/services/StockHistoryServiceTest.php | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/erp24/services/StockHistoryService.php b/erp24/services/StockHistoryService.php index 4a6430a9..ab0a1a85 100644 --- a/erp24/services/StockHistoryService.php +++ b/erp24/services/StockHistoryService.php @@ -255,9 +255,15 @@ class StockHistoryService return self::LOCK_TIMEOUT_SEC; } + protected function getLockRetrySleepUs(): int + { + return 500000; // 0.5 sec + } + private function acquireLock(): void { $deadline = time() + $this->getLockTimeoutSec(); + $sleepUs = $this->getLockRetrySleepUs(); while (time() < $deadline) { $locked = $this->db->createCommand() @@ -268,7 +274,7 @@ class StockHistoryService return; } - usleep(500000); // 0.5 sec + usleep($sleepUs); } $msg = 'Failed to acquire advisory lock within ' . $this->getLockTimeoutSec() . ' seconds'; diff --git a/erp24/tests/unit/services/StockHistoryServiceTest.php b/erp24/tests/unit/services/StockHistoryServiceTest.php index 56ca736c..19e65085 100644 --- a/erp24/tests/unit/services/StockHistoryServiceTest.php +++ b/erp24/tests/unit/services/StockHistoryServiceTest.php @@ -82,9 +82,10 @@ class StockHistoryServiceTest extends Unit $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('advisory lock'); - // Анонимный класс с timeout=1 сек для быстрого теста + // Анонимный класс с минимальными таймаутами для быстрого теста $service = new class($db) extends StockHistoryService { protected function getLockTimeoutSec(): int { return 1; } + protected function getLockRetrySleepUs(): int { return 100000; } // 0.1 sec }; $service->collect('08:00'); } -- 2.39.5