From ef3d38c5a65fb0bbbfd209238587092c43b3023d Mon Sep 17 00:00:00 2001 From: Divyansha Dubey Date: Fri, 12 Sep 2025 17:48:15 +0400 Subject: [PATCH 1/7] fixed db stats env var --- .../Platform/Modules/Databases/Http/Databases/Usage/Get.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php index 4770d727a0..c9de9d5217 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Usage/Get.php @@ -77,8 +77,8 @@ class Get extends Action str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_COLLECTIONS), str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_DOCUMENTS), str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_STORAGE), - str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASES_OPERATIONS_READS), - str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASES_OPERATIONS_WRITES) + str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_READS), + str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_WRITES) ]; Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) { From 39a190f60c98c13398f145f92af73e0ac8c77e95 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 12 Sep 2025 10:07:40 +0100 Subject: [PATCH 2/7] fix: db queues --- app/controllers/api/health.php | 2 +- src/Appwrite/Event/Database.php | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index 988f061ed5..765688e1ee 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -538,7 +538,7 @@ App::get('/v1/health/queue/databases') ->inject('response') ->action(function (string $name, int|string $threshold, Database $queueForDatabase, Response $response) { $threshold = \intval($threshold); - $size = $queueForDatabase->getSize(); + $size = $queueForDatabase->setQueue($name)->getSize(); if ($size >= $threshold) { throw new Exception(Exception::HEALTH_QUEUE_SIZE_EXCEEDED, "Queue size threshold hit. Current size is {$size} and threshold is {$threshold}."); diff --git a/src/Appwrite/Event/Database.php b/src/Appwrite/Event/Database.php index 70051f9055..8e7f6b7625 100644 --- a/src/Appwrite/Event/Database.php +++ b/src/Appwrite/Event/Database.php @@ -161,17 +161,20 @@ class Database extends Event return $this->document; } - public function getQueue(): string + public function setProject(Document $project): self { - try { - $dsn = new DSN($this->getProject()->getAttribute('database')); - } catch (\InvalidArgumentException) { - // TODO: Temporary until all projects are using shared tables - $dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database')); + $database = $project->getAttribute('database'); + if (!empty($database)) { + try { + $dsn = new DSN($database); + } catch (\InvalidArgumentException) { + // TODO: Temporary until all projects are using shared tables + $dsn = new DSN("mysql://$database"); + } + $this->queue = $dsn->getHost(); } - $this->queue = $dsn->getHost(); - return $this->queue; + return parent::setProject($project); } /** From 3114f572df92cf45f5f24da07c98aac620111803 Mon Sep 17 00:00:00 2001 From: Darshan Date: Sat, 13 Sep 2025 12:33:19 +0530 Subject: [PATCH 3/7] update: `package.json` for smaller sizes. --- package.json | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6e32c7d515..1e2b1be430 100644 --- a/package.json +++ b/package.json @@ -4,5 +4,9 @@ "repository": { "type": "git", "url": "git+https://github.com/appwrite/appwrite.git" - } -} \ No newline at end of file + }, + "files": [ + "docs/examples", + "app/config/specs" + ] +} From fcd23e2a740bc427720589d2c60fa95cd6c2f6d4 Mon Sep 17 00:00:00 2001 From: Darshan Date: Sat, 13 Sep 2025 12:53:06 +0530 Subject: [PATCH 4/7] ci: empty commit From c140dd6fbbd131c5fccdf4446e416011ed16ff5e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 14 Sep 2025 10:58:21 +1200 Subject: [PATCH 5/7] Move disable --- app/controllers/shared/api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/shared/api.php b/app/controllers/shared/api.php index 6dcb99b56f..959ee77b7d 100644 --- a/app/controllers/shared/api.php +++ b/app/controllers/shared/api.php @@ -246,10 +246,11 @@ App::init() $role = $apiKey->getRole(); $scopes = $apiKey->getScopes(); - // Disable authorization checks for API keys - Authorization::setDefaultStatus(false); if ($apiKey->getRole() === Auth::USER_ROLE_APPS) { + // Disable authorization checks for API keys + Authorization::setDefaultStatus(false); + $user = new Document([ '$id' => '', 'status' => true, From 30dde4c2f4c751c6b6498569ee402954f3180ce1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sun, 14 Sep 2025 11:00:32 +1200 Subject: [PATCH 6/7] Trigger CI From 66503a4e806048b540d334474558ba9a121a5a49 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Mon, 15 Sep 2025 15:15:56 +0100 Subject: [PATCH 7/7] fix: api worker-stop --- app/http.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/http.php b/app/http.php index 30f4013821..1bd3e97e69 100644 --- a/app/http.php +++ b/app/http.php @@ -10,6 +10,7 @@ use Swoole\Http\Response as SwooleResponse; use Swoole\Http\Server; use Swoole\Process; use Swoole\Table; +use Swoole\Timer; use Utopia\App; use Utopia\Audit\Audit; use Utopia\CLI\Console; @@ -156,11 +157,16 @@ $http->on(Constant::EVENT_WORKER_START, function ($server, $workerId) { Console::success('Worker ' . ++$workerId . ' started successfully'); }); -$http->on(Constant::EVENT_BEFORE_RELOAD, function ($server, $workerId) { +$http->on(Constant::EVENT_WORKER_STOP, function ($server, $workerId) { + Timer::clearAll(); + Console::success('Worker ' . ++$workerId . ' stopped successfully'); +}); + +$http->on(Constant::EVENT_BEFORE_RELOAD, function ($server) { Console::success('Starting reload...'); }); -$http->on(Constant::EVENT_AFTER_RELOAD, function ($server, $workerId) { +$http->on(Constant::EVENT_AFTER_RELOAD, function ($server) { Console::success('Reload completed...'); }); @@ -550,7 +556,7 @@ $http->on(Constant::EVENT_TASK, function () use ($register, $domains) { /** @var Utopia\Database\Database $dbForPlatform */ $dbForPlatform = $app->getResource('dbForPlatform'); - Console::loop(function () use ($dbForPlatform, $domains, &$lastSyncUpdate) { + Timer::tick(DOMAIN_SYNC_TIMER * 1000, function () use ($dbForPlatform, $domains, &$lastSyncUpdate) { try { $time = DateTime::now(); $limit = 1000; @@ -589,8 +595,6 @@ $http->on(Constant::EVENT_TASK, function () use ($register, $domains) { } catch (Throwable $th) { Console::error($th->getMessage()); } - }, DOMAIN_SYNC_TIMER, 0, function ($error) { - Console::error($error); }); });