2323 */
2424final class TaskRepairCandidates
2525{
26+ private const TIMESTAMP_FORMAT = 'Y-m-d H:i:s.u ' ;
27+
2628 /**
2729 * @return list<string>
2830 */
@@ -685,15 +687,16 @@ private static function existingTaskQuery(
685687 $ now ??= now ();
686688 $ staleDispatchCutoff = $ now ->copy ()
687689 ->subSeconds (TaskRepairPolicy::redispatchAfterSeconds ())
688- ->format (' Y-m-d H:i:s.u ' );
690+ ->format (self :: TIMESTAMP_FORMAT );
689691
692+ // DateTime query bindings lose the fractional precision stored by the task model.
690693 $ query = WorkflowTask::query ()
691694 ->where (static function ($ query ) use ($ now , $ staleDispatchCutoff ): void {
692695 $ query ->where (static function ($ ready ) use ($ now , $ staleDispatchCutoff ): void {
693696 $ ready ->where ('status ' , TaskStatus::Ready->value )
694697 ->where (static function ($ available ) use ($ now ): void {
695698 $ available ->whereNull ('available_at ' )
696- ->orWhere ('available_at ' , '<= ' , $ now );
699+ ->orWhere ('available_at ' , '<= ' , $ now-> format ( self :: TIMESTAMP_FORMAT ) );
697700 })
698701 ->where (static function ($ repairable ) use ($ now , $ staleDispatchCutoff ): void {
699702 $ repairable
@@ -710,7 +713,11 @@ private static function existingTaskQuery(
710713 $ claimRepairable
711714 ->where (static function ($ backoffReady ) use ($ now ): void {
712715 $ backoffReady ->whereNotNull ('repair_available_at ' )
713- ->where ('repair_available_at ' , '<= ' , $ now );
716+ ->where (
717+ 'repair_available_at ' ,
718+ '<= ' ,
719+ $ now ->format (self ::TIMESTAMP_FORMAT )
720+ );
714721 })
715722 ->orWhere (static function ($ legacyClaimFailure ) use (
716723 $ staleDispatchCutoff
@@ -746,7 +753,7 @@ private static function existingTaskQuery(
746753 })->orWhere (static function ($ leased ) use ($ now ): void {
747754 $ leased ->where ('status ' , TaskStatus::Leased->value )
748755 ->whereNotNull ('lease_expires_at ' )
749- ->where ('lease_expires_at ' , '<= ' , $ now );
756+ ->where ('lease_expires_at ' , '<= ' , $ now-> format ( self :: TIMESTAMP_FORMAT ) );
750757 });
751758 });
752759
@@ -885,7 +892,7 @@ private static function applyRepairBackoffReady($query, CarbonInterface $now): v
885892 {
886893 $ query ->where (static function ($ repairBackoff ) use ($ now ): void {
887894 $ repairBackoff ->whereNull ('repair_available_at ' )
888- ->orWhere ('repair_available_at ' , '<= ' , $ now );
895+ ->orWhere ('repair_available_at ' , '<= ' , $ now-> format ( self :: TIMESTAMP_FORMAT ) );
889896 });
890897 }
891898
0 commit comments