mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: disable execution document writes for nyc region
Temporarily skip all execution createDocument and updateDocument calls in the Functions worker when _APP_REGION is set to 'nyc' to reduce database load. Marked with TODO comments for removal.
This commit is contained in:
@@ -80,7 +80,9 @@ class Functions extends Action
|
||||
// Short-term solution to offhand write operation from API container
|
||||
if ($type === Func::TYPE_ASYNC_WRITE) {
|
||||
$execution = new Document($payload['execution'] ?? []);
|
||||
$dbForProject->createDocument('executions', $execution);
|
||||
if (System::getEnv('_APP_REGION') !== 'nyc') { // TODO: Remove region check
|
||||
$dbForProject->createDocument('executions', $execution);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -309,10 +311,12 @@ class Functions extends Action
|
||||
'duration' => 0.0,
|
||||
]);
|
||||
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
if (System::getEnv('_APP_REGION') !== 'nyc') { // TODO: Remove region check
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
|
||||
if ($execution->isEmpty()) {
|
||||
throw new Exception('Failed to create execution');
|
||||
if ($execution->isEmpty()) {
|
||||
throw new Exception('Failed to create execution');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,22 +455,26 @@ class Functions extends Action
|
||||
'duration' => 0.0,
|
||||
]);
|
||||
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
if (System::getEnv('_APP_REGION') !== 'nyc') { // TODO: Remove region check
|
||||
$execution = $dbForProject->createDocument('executions', $execution);
|
||||
|
||||
// TODO: @Meldiron Trigger executions.create event here
|
||||
// TODO: @Meldiron Trigger executions.create event here
|
||||
|
||||
if ($execution->isEmpty()) {
|
||||
throw new Exception('Failed to create or read execution');
|
||||
if ($execution->isEmpty()) {
|
||||
throw new Exception('Failed to create or read execution');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($execution->getAttribute('status') !== 'processing') {
|
||||
$execution->setAttribute('status', 'processing');
|
||||
|
||||
try {
|
||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
||||
} catch (\Throwable $e) {
|
||||
$log->addExtra('updateError', $e->getMessage());
|
||||
if (System::getEnv('_APP_REGION') !== 'nyc') { // TODO: Remove region check
|
||||
try {
|
||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
||||
} catch (\Throwable $e) {
|
||||
$log->addExtra('updateError', $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,10 +619,12 @@ class Functions extends Action
|
||||
$errorCode = $th->getCode();
|
||||
} finally {
|
||||
/** Update execution status */
|
||||
try {
|
||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
||||
} catch (\Throwable $e) {
|
||||
$log->addExtra('updateError', $e->getMessage());
|
||||
if (System::getEnv('_APP_REGION') !== 'nyc') { // TODO: Remove region check
|
||||
try {
|
||||
$execution = $dbForProject->updateDocument('executions', $executionId, $execution);
|
||||
} catch (\Throwable $e) {
|
||||
$log->addExtra('updateError', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/** Trigger usage queue */
|
||||
|
||||
Reference in New Issue
Block a user