fix: isolate tick errors per event, bound overlap lock

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
nikita.hohlov
2026-09-04 07:46:35 -03:00
parent affac4ce1a
commit 6138ac7bb0
3 changed files with 37 additions and 2 deletions

View File

@@ -17,7 +17,9 @@ use App\Scheduling\WindowResolver;
use Illuminate\Contracts\Cache\Repository as Cache;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;
use Throwable;
/**
* Один тик планировщика (раз в минуту): переходы состояний по датам и решение,
@@ -39,7 +41,15 @@ final class Tick
Event::query()
->whereIn('state', EventState::nonTerminalValues())
->with('user')
->chunkById(200, fn (Collection $events) => $events->each(fn (Event $e) => $this->process($e)));
->chunkById(200, function (Collection $events) {
foreach ($events as $event) {
try {
$this->process($event);
} catch (Throwable $e) {
Log::error('hado.tick: событие пропущено', ['event_id' => $event->id, 'error' => $e->getMessage()]);
}
}
});
}
private function process(Event $event): void