mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
1 parent
c2081a2230
commit
4ce89efe33
1 file changed
+2
-8
@@ -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),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user