From 4ce89efe33e0ee8ba5b1522adbf171dfb8f90482 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Sun, 21 Jun 2026 17:27:27 +0100 Subject: [PATCH] fix(deletes): run execution-limit cleanup sequentially to avoid shared-connection crash deleteExecutionsByLimit() fanned the two resource types out with Swoole\Coroutine\batch(), but both coroutines share one $dbForProject (getProjectDB caches the Database/Pool per host). When one coroutine opens a delete transaction the Pool adapter pins that connection in a process-global field and routes the sibling coroutine's reads onto it, producing "2014 Cannot execute queries while other unbuffered queries are active" and crashing the worker. Process the resource types sequentially so only one transaction holds the connection at a time. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/Appwrite/Platform/Workers/Deletes.php | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 9eda3dbd52..1ac808c682 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -1106,7 +1106,7 @@ class Deletes extends Action // fast path, no need to list anything! $delete($dbForProject, $resourceInternalId, $resourceType); } else { - $processResource = function (string $type) use ($dbForProject, $delete) { + foreach ([RESOURCE_TYPE_SITES, RESOURCE_TYPE_FUNCTIONS] as $type) { $this->listByGroup( collection: $type, queries: [Query::select(['$id', '$sequence'])], @@ -1115,13 +1115,7 @@ class Deletes extends Action $delete($dbForProject, $resource->getSequence(), $type); } ); - }; - - /* perform processing in parallel */ - batch([ - fn () => $processResource(RESOURCE_TYPE_SITES), - fn () => $processResource(RESOURCE_TYPE_FUNCTIONS), - ]); + } } }