Skip to content

Commit 4c79ebf

Browse files
Pin available_at filter cutoff to microsecond precision in drainReadyTasks
The drainReadyTasks helpers added in d042ea9 (V2WorkflowTest) and b5ce150 (V2RunDetailViewTest) bound a Carbon now() instance to the available_at SQL filter. Eloquent serialized the Carbon to second precision before binding, so the comparison `available_at <= now()` returned false when the row was created within the same wall-clock second as the filter (microseconds 597278 > seconds-only 0). Symptom: drainReadyTasks would skip the freshly-dispatched workflow start task because its available_at (set to now() during dispatch) was bound as a microsecond timestamp in the column but compared against a truncated filter value, leaving the workflow stuck at status=pending. Fix the filter to format the cutoff with microsecond precision via `now()->format('Y-m-d H:i:s.u')` so the bound parameter and the stored column compare consistently on both MySQL and PostgreSQL. Clears the latent failure in any drainReadyTasks-driven test where the start task fires within the same wall-clock second as the drain. Verified locally with Postgres: testWorkflowActivityHeartbeatPersistsAttemptMetadata and the seven d042ea9 timer-cancel tests now pass; the six b5ce150 RunDetailView conversions also still pass under the new filter shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2a90654 commit 4c79ebf

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

tests/Feature/V2/V2RunDetailViewTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3823,12 +3823,15 @@ private function drainReadyTasks(): void
38233823
$deadline = microtime(true) + 10;
38243824

38253825
while (microtime(true) < $deadline) {
3826+
$cutoff = now()
3827+
->format('Y-m-d H:i:s.u');
3828+
38263829
/** @var WorkflowTask|null $task */
38273830
$task = WorkflowTask::query()
38283831
->where('status', TaskStatus::Ready->value)
3829-
->where(static function ($query): void {
3832+
->where(static function ($query) use ($cutoff): void {
38303833
$query->whereNull('available_at')
3831-
->orWhere('available_at', '<=', now());
3834+
->orWhere('available_at', '<=', $cutoff);
38323835
})
38333836
->orderBy('created_at')
38343837
->first();

tests/Feature/V2/V2WorkflowTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8115,12 +8115,15 @@ private function drainReadyTasks(): void
81158115
$deadline = microtime(true) + 10;
81168116

81178117
while (microtime(true) < $deadline) {
8118+
$cutoff = now()
8119+
->format('Y-m-d H:i:s.u');
8120+
81188121
/** @var WorkflowTask|null $task */
81198122
$task = WorkflowTask::query()
81208123
->where('status', TaskStatus::Ready->value)
8121-
->where(static function ($query): void {
8124+
->where(static function ($query) use ($cutoff): void {
81228125
$query->whereNull('available_at')
8123-
->orWhere('available_at', '<=', now());
8126+
->orWhere('available_at', '<=', $cutoff);
81248127
})
81258128
->orderBy('created_at')
81268129
->first();

0 commit comments

Comments
 (0)