From: Auto-Claude Orchestrator Date: Tue, 24 Mar 2026 07:30:52 +0000 (+0000) Subject: feat(task-JIRA-ERP-33-20260324070448): Сбор данных по остаткам на день X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ddd16bc3b14b7a7a511d00b7632c8adf65b16be2;p=erp24_rep%2Fyii-erp24%2F.git feat(task-JIRA-ERP-33-20260324070448): Сбор данных по остаткам на день --- 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'); }