From 6eb206fc40c62203fbebbe9a37d63f45ce353d57 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 17 Sep 2026 16:49:57 +0100 Subject: [PATCH 1/3] feat(schedule): name the schedule a reconcile failure belongs to A reconcile failure reported the throwable and nothing else, so an error like "Collection not found" arrived carrying its region and no way to tell which of several thousand schedules produced it. Finding one meant writing a task to re-derive it from the database. utopia-php/schedule 0.3.0 passes the rejected row to the handler, so each of the three schedulers now tags the project, resource and schedule it was building -- the same attributes the enqueue path already records on the success side. --- composer.json | 2 +- composer.lock | 14 +++++++------- src/Appwrite/Platform/Tasks/ScheduleExecutions.php | 10 +++++++++- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 11 ++++++++++- src/Appwrite/Platform/Tasks/ScheduleMessages.php | 10 +++++++++- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 587dd90749..39f412bb4a 100644 --- a/composer.json +++ b/composer.json @@ -121,7 +121,7 @@ "enshrined/svg-sanitize": "0.22.*", "utopia-php/client": "^0.4.4", "open-runtimes/sdk-for-php": "^2.0", - "utopia-php/schedule": "^0.2.0", + "utopia-php/schedule": "^0.3.0", "utopia-php/usage": "^0.16.4", "utopia-php/query": "0.6.*", "utopia-php/openapi": "^0.2.4", diff --git a/composer.lock b/composer.lock index 005febd297..108f563e87 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "59039ff57c3917eab949bc0daf0a9668", + "content-hash": "067e4c5b691b20b06213bc3c9382a6c9", "packages": [ { "name": "adhocore/jwt", @@ -4451,16 +4451,16 @@ }, { "name": "utopia-php/schedule", - "version": "0.2.2", + "version": "0.3.0", "source": { "type": "git", "url": "https://github.com/utopia-php/schedule.git", - "reference": "3a7ca5134df98830c6b2dd825324c46378f45f56" + "reference": "fd28416654405e865649569e111fe1d3a3cf9868" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/schedule/zipball/3a7ca5134df98830c6b2dd825324c46378f45f56", - "reference": "3a7ca5134df98830c6b2dd825324c46378f45f56", + "url": "https://api.github.com/repos/utopia-php/schedule/zipball/fd28416654405e865649569e111fe1d3a3cf9868", + "reference": "fd28416654405e865649569e111fe1d3a3cf9868", "shasum": "" }, "require": { @@ -4504,9 +4504,9 @@ ], "support": { "issues": "https://github.com/utopia-php/schedule/issues", - "source": "https://github.com/utopia-php/schedule/tree/0.2.2" + "source": "https://github.com/utopia-php/schedule/tree/0.3.0" }, - "time": "2026-08-19T10:25:02+00:00" + "time": "2026-09-17T15:41:29+00:00" }, { "name": "utopia-php/servers", diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 820fecd928..ca997845d6 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -10,6 +10,7 @@ use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Schedule\Occurrence; use Utopia\Schedule\Scheduler; +use Utopia\Schedule\Source\Row; use Utopia\Span\Span; use Utopia\Telemetry\Adapter as Telemetry; @@ -42,8 +43,15 @@ class ScheduleExecutions extends Action source: $source, syncSeconds: self::UPDATE_TIMER, telemetry: $telemetry, - onError: function (\Throwable $error): void { + onError: function (\Throwable $error, ?Row $row = null): void { Span::init('schedule.executions.reconcile'); + // The row a failure belongs to, so an error names one schedule + // rather than the region it happened in. + if ($row?->data instanceof Document) { + Span::add('project.id', (string) $row->data->getAttribute('projectId')); + Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); + Span::add('schedule.id', $row->id); + } Span::current()?->finish(error: $error); }, ); diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index f98d3efc5d..da3fe239d1 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -6,9 +6,11 @@ use Appwrite\Event\Message\Func as FunctionMessage; use Appwrite\Event\Publisher\Func as FunctionPublisher; use Appwrite\Schedule\Source; use Utopia\Database\Database; +use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Schedule\Occurrence; use Utopia\Schedule\Scheduler; +use Utopia\Schedule\Source\Row; use Utopia\Span\Span; use Utopia\System\System; use Utopia\Telemetry\Adapter as Telemetry; @@ -44,8 +46,15 @@ class ScheduleFunctions extends Action $scheduler = new Scheduler( source: $source, telemetry: $telemetry, - onError: function (\Throwable $error): void { + onError: function (\Throwable $error, ?Row $row = null): void { Span::init('schedule.functions.reconcile'); + // The row a failure belongs to, so an error names one schedule + // rather than the region it happened in. + if ($row?->data instanceof Document) { + Span::add('project.id', (string) $row->data->getAttribute('projectId')); + Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); + Span::add('schedule.id', $row->id); + } Span::current()?->finish(error: $error); }, ); diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 80f26d6bf2..82356d6c9a 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -11,6 +11,7 @@ use Utopia\Database\Document; use Utopia\Platform\Action; use Utopia\Schedule\Occurrence; use Utopia\Schedule\Scheduler; +use Utopia\Schedule\Source\Row; use Utopia\Span\Span; use Utopia\Telemetry\Adapter as Telemetry; @@ -49,8 +50,15 @@ class ScheduleMessages extends Action source: $source, syncSeconds: self::UPDATE_TIMER, telemetry: $telemetry, - onError: function (\Throwable $error): void { + onError: function (\Throwable $error, ?Row $row = null): void { Span::init('schedule.messages.reconcile'); + // The row a failure belongs to, so an error names one schedule + // rather than the region it happened in. + if ($row?->data instanceof Document) { + Span::add('project.id', (string) $row->data->getAttribute('projectId')); + Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); + Span::add('schedule.id', $row->id); + } Span::current()?->finish(error: $error); }, ); From c71e6fcbd7c7469ee05e2ccf41c322bc07229b77 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 17 Sep 2026 16:50:48 +0100 Subject: [PATCH 2/3] style(schedule): drop the comment on the reconcile error handlers --- src/Appwrite/Platform/Tasks/ScheduleExecutions.php | 2 -- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 2 -- src/Appwrite/Platform/Tasks/ScheduleMessages.php | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index ca997845d6..5e4aa3ea51 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -45,8 +45,6 @@ class ScheduleExecutions extends Action telemetry: $telemetry, onError: function (\Throwable $error, ?Row $row = null): void { Span::init('schedule.executions.reconcile'); - // The row a failure belongs to, so an error names one schedule - // rather than the region it happened in. if ($row?->data instanceof Document) { Span::add('project.id', (string) $row->data->getAttribute('projectId')); Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index da3fe239d1..ed69ae748e 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -48,8 +48,6 @@ class ScheduleFunctions extends Action telemetry: $telemetry, onError: function (\Throwable $error, ?Row $row = null): void { Span::init('schedule.functions.reconcile'); - // The row a failure belongs to, so an error names one schedule - // rather than the region it happened in. if ($row?->data instanceof Document) { Span::add('project.id', (string) $row->data->getAttribute('projectId')); Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 82356d6c9a..8160b12937 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -52,8 +52,6 @@ class ScheduleMessages extends Action telemetry: $telemetry, onError: function (\Throwable $error, ?Row $row = null): void { Span::init('schedule.messages.reconcile'); - // The row a failure belongs to, so an error names one schedule - // rather than the region it happened in. if ($row?->data instanceof Document) { Span::add('project.id', (string) $row->data->getAttribute('projectId')); Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); From d1463b467db9cf52cac76065e0aa8f66f7eab25c Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 17 Sep 2026 17:22:18 +0100 Subject: [PATCH 3/3] fix(schedule): tag the schedule document id, not its sequence Row::id is the sequence Source\Database::rows() builds it from, while the enqueue path tags $schedule['$id']. Reporting the sequence under the same key sent operators looking for an id that is not on the document. --- src/Appwrite/Platform/Tasks/ScheduleExecutions.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 2 +- src/Appwrite/Platform/Tasks/ScheduleMessages.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php index 5e4aa3ea51..326f4323a2 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleExecutions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleExecutions.php @@ -48,7 +48,7 @@ class ScheduleExecutions extends Action if ($row?->data instanceof Document) { Span::add('project.id', (string) $row->data->getAttribute('projectId')); Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); - Span::add('schedule.id', $row->id); + Span::add('schedule.id', $row->data->getId()); } Span::current()?->finish(error: $error); }, diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index ed69ae748e..e2253a2d88 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -51,7 +51,7 @@ class ScheduleFunctions extends Action if ($row?->data instanceof Document) { Span::add('project.id', (string) $row->data->getAttribute('projectId')); Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); - Span::add('schedule.id', $row->id); + Span::add('schedule.id', $row->data->getId()); } Span::current()?->finish(error: $error); }, diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 8160b12937..e58476c076 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -55,7 +55,7 @@ class ScheduleMessages extends Action if ($row?->data instanceof Document) { Span::add('project.id', (string) $row->data->getAttribute('projectId')); Span::add('resource.id', (string) $row->data->getAttribute('resourceId')); - Span::add('schedule.id', $row->id); + Span::add('schedule.id', $row->data->getId()); } Span::current()?->finish(error: $error); },