]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
feat(task-JIRA-ERP-33-20260324070448): Сбор данных по остаткам на день
authorAuto-Claude Orchestrator <orchestrator@auto-claude.local>
Tue, 24 Mar 2026 07:30:52 +0000 (07:30 +0000)
committerAuto-Claude Orchestrator <orchestrator@auto-claude.local>
Tue, 24 Mar 2026 07:30:52 +0000 (07:30 +0000)
erp24/services/StockHistoryService.php
erp24/tests/unit/services/StockHistoryServiceTest.php

index 4a6430a950db2a5f28de4056efad9e4e135bdea5..ab0a1a85035ceb176ec613e6e38d37dae25999fc 100644 (file)
@@ -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';
index 56ca736ca79f1070efab907ba02a9100a0d7b4f1..19e6508529974bf13ff13afb231a416bc355fdbd 100644 (file)
@@ -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');
     }