From a6779caa5ebf0eca8a080061fca91931a1e9842b Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 7 Nov 2024 14:28:39 +0200 Subject: [PATCH 01/22] Trigger sentry --- src/Appwrite/Platform/Workers/Databases.php | 24 ++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index f697e7be13..1974a0b959 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -92,6 +92,7 @@ class Databases extends Action * @throws Authorization * @throws Conflict * @throws \Exception + * @throws \Throwable */ private function createAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject): void { @@ -134,7 +135,6 @@ class Databases extends Action $options = $attribute->getAttribute('options', []); $project = $dbForConsole->getDocument('projects', $projectId); - try { switch ($type) { case Database::VAR_RELATIONSHIP: @@ -170,7 +170,6 @@ class Databases extends Action $dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'available')); } catch (\Throwable $e) { - // TODO: Send non DatabaseExceptions to Sentry Console::error($e->getMessage()); if ($e instanceof DatabaseException) { @@ -193,6 +192,9 @@ class Databases extends Action $relatedAttribute->setAttribute('status', 'failed') ); } + + // TODO: Send non DatabaseExceptions to Sentry + throw $e; } finally { $this->trigger($database, $collection, $attribute, $project, $projectId, $events); } @@ -215,6 +217,7 @@ class Databases extends Action * @throws Authorization * @throws Conflict * @throws \Exception + * @throws \Throwable **/ private function deleteAttribute(Document $database, Document $collection, Document $attribute, Document $project, Database $dbForConsole, Database $dbForProject): void { @@ -273,7 +276,6 @@ class Databases extends Action $dbForProject->deleteDocument('attributes', $relatedAttribute->getId()); } } catch (\Throwable $e) { - // TODO: Send non DatabaseExceptions to Sentry Console::error($e->getMessage()); if ($e instanceof DatabaseException) { @@ -294,6 +296,9 @@ class Databases extends Action $relatedAttribute->setAttribute('status', 'stuck') ); } + + // TODO: Send non DatabaseExceptions to Sentry + throw $e; } finally { $this->trigger($database, $collection, $attribute, $project, $projectId, $events); } @@ -370,6 +375,7 @@ class Databases extends Action * @throws Conflict * @throws Structure * @throws DatabaseException + * @throws \Throwable */ private function createIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject): void { @@ -401,7 +407,7 @@ class Databases extends Action } $dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'available')); } catch (\Throwable $e) { - // TODO: Send non DatabaseExceptions to Sentry + Console::error($e->getMessage()); if ($e instanceof DatabaseException) { @@ -412,6 +418,9 @@ class Databases extends Action $index->getId(), $index->setAttribute('status', 'failed') ); + + // TODO: Send non DatabaseExceptions to Sentry + throw $e; } finally { $this->trigger($database, $collection, $index, $project, $projectId, $events); } @@ -431,6 +440,7 @@ class Databases extends Action * @throws Conflict * @throws Structure * @throws DatabaseException + * @throws \Throwable */ private function deleteIndex(Document $database, Document $collection, Document $index, Document $project, Database $dbForConsole, Database $dbForProject): void { @@ -459,7 +469,6 @@ class Databases extends Action $dbForProject->deleteDocument('indexes', $index->getId()); $index->setAttribute('status', 'deleted'); } catch (\Throwable $e) { - // TODO: Send non DatabaseExceptions to Sentry Console::error($e->getMessage()); if ($e instanceof DatabaseException) { @@ -470,10 +479,15 @@ class Databases extends Action $index->getId(), $index->setAttribute('status', 'stuck') ); + + // TODO: Send non DatabaseExceptions to Sentry ? + throw $e; + } finally { $this->trigger($database, $collection, $index, $project, $projectId, $events); } + // Do we want this in finally? $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collection->getId()); } From 19667f78a92e00fa203a7a35bd4f4f13e2175851 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 7 Nov 2024 17:23:46 +0200 Subject: [PATCH 02/22] Add try catch on delete Attribute --- src/Appwrite/Platform/Workers/Databases.php | 180 ++++++++++---------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 1974a0b959..388dd3b88c 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -251,115 +251,118 @@ class Databases extends Action // - stuck: attribute was available but cannot be removed try { - if ($status !== 'failed') { - if ($type === Database::VAR_RELATIONSHIP) { - if ($options['twoWay']) { - $relatedCollection = $dbForProject->getDocument('database_' . $database->getInternalId(), $options['relatedCollection']); - if ($relatedCollection->isEmpty()) { - throw new DatabaseException('Collection not found'); + try { + if ($status !== 'failed') { + if ($type === Database::VAR_RELATIONSHIP) { + if ($options['twoWay']) { + $relatedCollection = $dbForProject->getDocument('database_' . $database->getInternalId(), $options['relatedCollection']); + if ($relatedCollection->isEmpty()) { + throw new DatabaseException('Collection not found'); + } + $relatedAttribute = $dbForProject->getDocument('attributes', $database->getInternalId() . '_' . $relatedCollection->getInternalId() . '_' . $options['twoWayKey']); } - $relatedAttribute = $dbForProject->getDocument('attributes', $database->getInternalId() . '_' . $relatedCollection->getInternalId() . '_' . $options['twoWayKey']); - } - if (!$dbForProject->deleteRelationship('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $key)) { - $dbForProject->updateDocument('attributes', $relatedAttribute->getId(), $relatedAttribute->setAttribute('status', 'stuck')); - throw new DatabaseException('Failed to delete Relationship'); + if (!$dbForProject->deleteRelationship('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $key)) { + $dbForProject->updateDocument('attributes', $relatedAttribute->getId(), $relatedAttribute->setAttribute('status', 'stuck')); + throw new DatabaseException('Failed to delete Relationship'); + } + } elseif (!$dbForProject->deleteAttribute('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $key)) { + throw new DatabaseException('Failed to delete Attribute'); } - } elseif (!$dbForProject->deleteAttribute('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $key)) { - throw new DatabaseException('Failed to delete Attribute'); } - } - $dbForProject->deleteDocument('attributes', $attribute->getId()); + $dbForProject->deleteDocument('attributes', $attribute->getId()); - if (!$relatedAttribute->isEmpty()) { - $dbForProject->deleteDocument('attributes', $relatedAttribute->getId()); - } - } catch (\Throwable $e) { - Console::error($e->getMessage()); - - if ($e instanceof DatabaseException) { - $attribute->setAttribute('error', $e->getMessage()); if (!$relatedAttribute->isEmpty()) { - $relatedAttribute->setAttribute('error', $e->getMessage()); + $dbForProject->deleteDocument('attributes', $relatedAttribute->getId()); + } + } catch (\Throwable $e) { + Console::error($e->getMessage()); + + if ($e instanceof DatabaseException) { + $attribute->setAttribute('error', $e->getMessage()); + if (!$relatedAttribute->isEmpty()) { + $relatedAttribute->setAttribute('error', $e->getMessage()); + } } - } - $dbForProject->updateDocument( - 'attributes', - $attribute->getId(), - $attribute->setAttribute('status', 'stuck') - ); - if (!$relatedAttribute->isEmpty()) { $dbForProject->updateDocument( 'attributes', - $relatedAttribute->getId(), - $relatedAttribute->setAttribute('status', 'stuck') + $attribute->getId(), + $attribute->setAttribute('status', 'stuck') ); + if (!$relatedAttribute->isEmpty()) { + $dbForProject->updateDocument( + 'attributes', + $relatedAttribute->getId(), + $relatedAttribute->setAttribute('status', 'stuck') + ); + } + + // TODO: Send non DatabaseExceptions to Sentry + throw $e; + } finally { + $this->trigger($database, $collection, $attribute, $project, $projectId, $events); } - // TODO: Send non DatabaseExceptions to Sentry - throw $e; - } finally { - $this->trigger($database, $collection, $attribute, $project, $projectId, $events); - } + // The underlying database removes/rebuilds indexes when attribute is removed + // Update indexes table with changes + /** @var Document[] $indexes */ + $indexes = $collection->getAttribute('indexes', []); - // The underlying database removes/rebuilds indexes when attribute is removed - // Update indexes table with changes - /** @var Document[] $indexes */ - $indexes = $collection->getAttribute('indexes', []); + foreach ($indexes as $index) { + /** @var string[] $attributes */ + $attributes = $index->getAttribute('attributes'); + $lengths = $index->getAttribute('lengths'); + $orders = $index->getAttribute('orders'); - foreach ($indexes as $index) { - /** @var string[] $attributes */ - $attributes = $index->getAttribute('attributes'); - $lengths = $index->getAttribute('lengths'); - $orders = $index->getAttribute('orders'); + $found = \array_search($key, $attributes); - $found = \array_search($key, $attributes); + if ($found !== false) { + // If found, remove entry from attributes, lengths, and orders + // array_values wraps array_diff to reindex array keys + // when found attribute is removed from array + $attributes = \array_values(\array_diff($attributes, [$attributes[$found]])); + $lengths = \array_values(\array_diff($lengths, isset($lengths[$found]) ? [$lengths[$found]] : [])); + $orders = \array_values(\array_diff($orders, isset($orders[$found]) ? [$orders[$found]] : [])); - if ($found !== false) { - // If found, remove entry from attributes, lengths, and orders - // array_values wraps array_diff to reindex array keys - // when found attribute is removed from array - $attributes = \array_values(\array_diff($attributes, [$attributes[$found]])); - $lengths = \array_values(\array_diff($lengths, isset($lengths[$found]) ? [$lengths[$found]] : [])); - $orders = \array_values(\array_diff($orders, isset($orders[$found]) ? [$orders[$found]] : [])); - - if (empty($attributes)) { - $dbForProject->deleteDocument('indexes', $index->getId()); - } else { - $index - ->setAttribute('attributes', $attributes, Document::SET_TYPE_ASSIGN) - ->setAttribute('lengths', $lengths, Document::SET_TYPE_ASSIGN) - ->setAttribute('orders', $orders, Document::SET_TYPE_ASSIGN); - - // Check if an index exists with the same attributes and orders - $exists = false; - foreach ($indexes as $existing) { - if ( - $existing->getAttribute('key') !== $index->getAttribute('key') // Ignore itself - && $existing->getAttribute('attributes') === $index->getAttribute('attributes') - && $existing->getAttribute('orders') === $index->getAttribute('orders') - ) { - $exists = true; - break; - } - } - - if ($exists) { // Delete the duplicate if created, else update in db - $this->deleteIndex($database, $collection, $index, $project, $dbForConsole, $dbForProject); + if (empty($attributes)) { + $dbForProject->deleteDocument('indexes', $index->getId()); } else { - $dbForProject->updateDocument('indexes', $index->getId(), $index); + $index + ->setAttribute('attributes', $attributes, Document::SET_TYPE_ASSIGN) + ->setAttribute('lengths', $lengths, Document::SET_TYPE_ASSIGN) + ->setAttribute('orders', $orders, Document::SET_TYPE_ASSIGN); + + // Check if an index exists with the same attributes and orders + $exists = false; + foreach ($indexes as $existing) { + if ( + $existing->getAttribute('key') !== $index->getAttribute('key') // Ignore itself + && $existing->getAttribute('attributes') === $index->getAttribute('attributes') + && $existing->getAttribute('orders') === $index->getAttribute('orders') + ) { + $exists = true; + break; + } + } + + if ($exists) { // Delete the duplicate if created, else update in db + $this->deleteIndex($database, $collection, $index, $project, $dbForConsole, $dbForProject); + } else { + $dbForProject->updateDocument('indexes', $index->getId(), $index); + } } } } - } - $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); - $dbForProject->purgeCachedCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId()); + } finally { + $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); + $dbForProject->purgeCachedCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId()); - if (!$relatedCollection->isEmpty() && !$relatedAttribute->isEmpty()) { - $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId()); - $dbForProject->purgeCachedCollection('database_' . $database->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); + if (!$relatedCollection->isEmpty() && !$relatedAttribute->isEmpty()) { + $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId()); + $dbForProject->purgeCachedCollection('database_' . $database->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); + } } } @@ -480,15 +483,12 @@ class Databases extends Action $index->setAttribute('status', 'stuck') ); - // TODO: Send non DatabaseExceptions to Sentry ? throw $e; } finally { $this->trigger($database, $collection, $index, $project, $projectId, $events); + $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collection->getId()); } - - // Do we want this in finally? - $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collection->getId()); } /** From cd0d1d94dbb56936091d07cd380180e4b857562d Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 7 Nov 2024 17:27:56 +0200 Subject: [PATCH 03/22] Add to finally --- src/Appwrite/Platform/Workers/Databases.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 388dd3b88c..8c26ca6cea 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -197,13 +197,12 @@ class Databases extends Action throw $e; } finally { $this->trigger($database, $collection, $attribute, $project, $projectId, $events); - } + if ($type === Database::VAR_RELATIONSHIP && $options['twoWay']) { + $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId()); + } - if ($type === Database::VAR_RELATIONSHIP && $options['twoWay']) { - $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId()); + $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); } - - $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); } /** @@ -426,9 +425,9 @@ class Databases extends Action throw $e; } finally { $this->trigger($database, $collection, $index, $project, $projectId, $events); + $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); } - $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); } /** From fb40970eba10f55596db980d89f0e1598d71ab43 Mon Sep 17 00:00:00 2001 From: fogelito Date: Thu, 7 Nov 2024 17:35:03 +0200 Subject: [PATCH 04/22] line --- src/Appwrite/Platform/Workers/Databases.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 8c26ca6cea..01f73018f4 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -197,6 +197,7 @@ class Databases extends Action throw $e; } finally { $this->trigger($database, $collection, $attribute, $project, $projectId, $events); + if ($type === Database::VAR_RELATIONSHIP && $options['twoWay']) { $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $relatedCollection->getId()); } From 06274764c645a7678e071fc17fa8512b4e206a75 Mon Sep 17 00:00:00 2001 From: fogelito Date: Fri, 8 Nov 2024 07:12:23 +0200 Subject: [PATCH 05/22] Remove extra lines --- src/Appwrite/Platform/Workers/Databases.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 01f73018f4..7cff9f264a 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -354,7 +354,6 @@ class Databases extends Action } } } - } finally { $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); $dbForProject->purgeCachedCollection('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId()); @@ -410,10 +409,14 @@ class Databases extends Action } $dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'available')); } catch (\Throwable $e) { - Console::error($e->getMessage()); - + Console::error('shmuel::createIndex'); if ($e instanceof DatabaseException) { + Console::error('shmuel::createIndex' . $e->getMessage()); + Console::error('shmuel::createIndex' . $e->getMessage()); + Console::error('shmuel::createIndex' . $e->getMessage()); + Console::error('shmuel::createIndex' . $e->getMessage()); + Console::error('shmuel::createIndex' . $e->getMessage()); $index->setAttribute('error', $e->getMessage()); } $dbForProject->updateDocument( @@ -428,7 +431,6 @@ class Databases extends Action $this->trigger($database, $collection, $index, $project, $projectId, $events); $dbForProject->purgeCachedDocument('database_' . $database->getInternalId(), $collectionId); } - } /** From 627df0d11fc403e2d084dd9746f24b6e4eb46edf Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 20:24:55 +0100 Subject: [PATCH 06/22] chore: remove redundant compression --- app/http.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/http.php b/app/http.php index 641143694d..b9e3552efd 100644 --- a/app/http.php +++ b/app/http.php @@ -60,8 +60,6 @@ include __DIR__ . '/controllers/general.php'; $http->on(Constant::EVENT_START, function (Server $http) use ($payloadSize, $register) { $app = new App('UTC'); - $app->setCompression(true); - $app->setCompressionMinSize(intval(System::getEnv('_APP_COMPRESSION_MIN_SIZE_BYTES', '1024'))); // 1KB go(function () use ($register, $app) { $pools = $register->get('pools'); From 2f9b44930f7c8a7b1460ed7c9d304c625a77b0a1 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:48:27 +0100 Subject: [PATCH 07/22] Revert "Merge pull request #8946 from appwrite/chore-update-database" This reverts commit c0bd1664be78456a57e766205c902d4f3740fe8a, reversing changes made to b42dd86451ac5bd23e46747fb158c990f4596b74. --- app/config/errors.php | 2 +- app/controllers/api/databases.php | 6 ++--- composer.json | 2 +- composer.lock | 26 +++++++++---------- .../Databases/DatabasesCustomServerTest.php | 2 +- 5 files changed, 18 insertions(+), 20 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index f09d1596eb..3afec4faaf 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -686,7 +686,7 @@ return [ ], Exception::ATTRIBUTE_LIMIT_EXCEEDED => [ 'name' => Exception::ATTRIBUTE_LIMIT_EXCEEDED, - 'description' => 'The maximum number or size of attributes for this collection has been reached.', + 'description' => 'The maximum number of attributes has been reached.', 'code' => 400, ], Exception::ATTRIBUTE_VALUE_INVALID => [ diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index dcf5bbffa5..0114fd343c 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -153,7 +153,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att } catch (DuplicateException) { throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $collectionId); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId()); @@ -197,7 +197,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { $dbForProject->deleteDocument('attributes', $attribute->getId()); - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); @@ -393,8 +393,6 @@ function updateAttribute( throw new Exception(Exception::ATTRIBUTE_INVALID_RESIZE); } catch (NotFoundException) { throw new Exception(Exception::ATTRIBUTE_NOT_FOUND); - } catch (LimitException) { - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } } diff --git a/composer.json b/composer.json index 5c2441fd1b..a04ca51d43 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.19", + "utopia-php/database": "0.53.16", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 097cee9868..2724542a38 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": "5be1b916c221b97b77b0e7f14491aabf", + "content-hash": "b358198535c1867eabed7c0f99135a57", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.19", + "version": "0.53.16", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "48951885f2787df30ad8581a0e94423558619daa" + "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", - "reference": "48951885f2787df30ad8581a0e94423558619daa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/6661edffeef05b59e16d102b989a72f7f78cf7de", + "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.19" + "source": "https://github.com/utopia-php/database/tree/0.53.16" }, - "time": "2024-11-08T07:00:24+00:00" + "time": "2024-11-06T03:07:16+00:00" }, { "name": "utopia-php/domains", @@ -6923,16 +6923,16 @@ }, { "name": "twig/twig", - "version": "v3.14.2", + "version": "v3.14.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" + "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", - "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", + "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", "shasum": "" }, "require": { @@ -6986,7 +6986,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.2" + "source": "https://github.com/twigphp/Twig/tree/v3.14.1" }, "funding": [ { @@ -6998,7 +6998,7 @@ "type": "tidelift" } ], - "time": "2024-11-07T12:36:22+00:00" + "time": "2024-11-06T18:17:38+00:00" }, { "name": "webmozart/glob", diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index b501e2119e..7cb8adb815 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -1362,7 +1362,7 @@ class DatabasesCustomServerTest extends Scope ]); $this->assertEquals(400, $tooWide['headers']['status-code']); - $this->assertEquals('attribute_limit_exceeded', $tooWide['body']['type']); + $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); } public function testIndexLimitException() From f6de25622008ad9510a553cfc8969f41b0ab39a3 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Fri, 8 Nov 2024 21:50:33 +0100 Subject: [PATCH 08/22] chore: composer update --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 2724542a38..828153a153 100644 --- a/composer.lock +++ b/composer.lock @@ -6923,16 +6923,16 @@ }, { "name": "twig/twig", - "version": "v3.14.1", + "version": "v3.14.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "shasum": "" }, "require": { @@ -6986,7 +6986,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.1" + "source": "https://github.com/twigphp/Twig/tree/v3.14.2" }, "funding": [ { @@ -6998,7 +6998,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T18:17:38+00:00" + "time": "2024-11-07T12:36:22+00:00" }, { "name": "webmozart/glob", From e5730506ebf5c8f8cda94434d89b3d9013c0b66d Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 10 Nov 2024 16:37:44 +0200 Subject: [PATCH 09/22] Remove var dumps --- src/Appwrite/Platform/Workers/Databases.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index 7cff9f264a..accc003976 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -410,13 +410,7 @@ class Databases extends Action $dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'available')); } catch (\Throwable $e) { Console::error($e->getMessage()); - Console::error('shmuel::createIndex'); if ($e instanceof DatabaseException) { - Console::error('shmuel::createIndex' . $e->getMessage()); - Console::error('shmuel::createIndex' . $e->getMessage()); - Console::error('shmuel::createIndex' . $e->getMessage()); - Console::error('shmuel::createIndex' . $e->getMessage()); - Console::error('shmuel::createIndex' . $e->getMessage()); $index->setAttribute('error', $e->getMessage()); } $dbForProject->updateDocument( From a85b43654cec1b02cf7e341cdf6c90af5acf4194 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 11 Nov 2024 15:22:57 +1300 Subject: [PATCH 10/22] Reapply "Update database" This reverts commit b1a1ad618a553efe42157306d2f6c59e6444892c. --- app/config/errors.php | 2 +- app/controllers/api/databases.php | 6 +++-- composer.json | 2 +- composer.lock | 26 +++++++++---------- .../Databases/DatabasesCustomServerTest.php | 2 +- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/app/config/errors.php b/app/config/errors.php index 3afec4faaf..f09d1596eb 100644 --- a/app/config/errors.php +++ b/app/config/errors.php @@ -686,7 +686,7 @@ return [ ], Exception::ATTRIBUTE_LIMIT_EXCEEDED => [ 'name' => Exception::ATTRIBUTE_LIMIT_EXCEEDED, - 'description' => 'The maximum number of attributes has been reached.', + 'description' => 'The maximum number or size of attributes for this collection has been reached.', 'code' => 400, ], Exception::ATTRIBUTE_VALUE_INVALID => [ diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 0114fd343c..dcf5bbffa5 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -153,7 +153,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att } catch (DuplicateException) { throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $collectionId); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $collection->getInternalId()); @@ -197,7 +197,7 @@ function createAttribute(string $databaseId, string $collectionId, Document $att throw new Exception(Exception::ATTRIBUTE_ALREADY_EXISTS); } catch (LimitException) { $dbForProject->deleteDocument('attributes', $attribute->getId()); - throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED, 'Attribute limit exceeded'); + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } catch (\Throwable $e) { $dbForProject->purgeCachedDocument('database_' . $db->getInternalId(), $relatedCollection->getId()); $dbForProject->purgeCachedCollection('database_' . $db->getInternalId() . '_collection_' . $relatedCollection->getInternalId()); @@ -393,6 +393,8 @@ function updateAttribute( throw new Exception(Exception::ATTRIBUTE_INVALID_RESIZE); } catch (NotFoundException) { throw new Exception(Exception::ATTRIBUTE_NOT_FOUND); + } catch (LimitException) { + throw new Exception(Exception::ATTRIBUTE_LIMIT_EXCEEDED); } } diff --git a/composer.json b/composer.json index a04ca51d43..5c2441fd1b 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.16", + "utopia-php/database": "0.53.19", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 691a7e740e..3ceb3e6106 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": "b358198535c1867eabed7c0f99135a57", + "content-hash": "5be1b916c221b97b77b0e7f14491aabf", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.16", + "version": "0.53.19", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de" + "reference": "48951885f2787df30ad8581a0e94423558619daa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/6661edffeef05b59e16d102b989a72f7f78cf7de", - "reference": "6661edffeef05b59e16d102b989a72f7f78cf7de", + "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", + "reference": "48951885f2787df30ad8581a0e94423558619daa", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.16" + "source": "https://github.com/utopia-php/database/tree/0.53.19" }, - "time": "2024-11-06T03:07:16+00:00" + "time": "2024-11-08T07:00:24+00:00" }, { "name": "utopia-php/domains", @@ -6923,16 +6923,16 @@ }, { "name": "twig/twig", - "version": "v3.14.1", + "version": "v3.14.2", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379" + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f405356d20fb43603bcadc8b09bfb676cb04a379", - "reference": "f405356d20fb43603bcadc8b09bfb676cb04a379", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", + "reference": "0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a", "shasum": "" }, "require": { @@ -6986,7 +6986,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.14.1" + "source": "https://github.com/twigphp/Twig/tree/v3.14.2" }, "funding": [ { @@ -6998,7 +6998,7 @@ "type": "tidelift" } ], - "time": "2024-11-06T18:17:38+00:00" + "time": "2024-11-07T12:36:22+00:00" }, { "name": "webmozart/glob", diff --git a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php index 7cb8adb815..b501e2119e 100644 --- a/tests/e2e/Services/Databases/DatabasesCustomServerTest.php +++ b/tests/e2e/Services/Databases/DatabasesCustomServerTest.php @@ -1362,7 +1362,7 @@ class DatabasesCustomServerTest extends Scope ]); $this->assertEquals(400, $tooWide['headers']['status-code']); - $this->assertEquals('Attribute limit exceeded', $tooWide['body']['message']); + $this->assertEquals('attribute_limit_exceeded', $tooWide['body']['type']); } public function testIndexLimitException() From d9e2ecff54fba52489e393ea5168a1d908d968f8 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 11 Nov 2024 16:45:17 +0900 Subject: [PATCH 11/22] Remove get document from worker --- src/Appwrite/Platform/Workers/Migrations.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index d430d0eb67..4b1926ed26 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -268,8 +268,6 @@ class Migrations extends Action $transfer = $source = $destination = null; try { - $migration = $this->dbForProject->getDocument('migrations', $migration->getId()); - if ( $migration->getAttribute('source') === SourceAppwrite::getName() && empty($migration->getAttribute('credentials', [])) From b0852aeca3dcc80d78ca63f9e75b365c9e098084 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 11 Nov 2024 23:15:00 +1300 Subject: [PATCH 12/22] Update database --- composer.json | 2 +- composer.lock | 28 ++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 2f5c229a5d..b82e4a55a3 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.18", + "utopia-php/database": "0.53.19", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index 14a3a7ee36..c01ce6545e 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": "bd9b8f5f8fe295deb07002ca0a953949", + "content-hash": "73a05899db73e80a2b9c66dbbfb8562e", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.18", + "version": "0.53.19", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "895176b61b969d326bf2e36695606b8a33132094" + "reference": "48951885f2787df30ad8581a0e94423558619daa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/895176b61b969d326bf2e36695606b8a33132094", - "reference": "895176b61b969d326bf2e36695606b8a33132094", + "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", + "reference": "48951885f2787df30ad8581a0e94423558619daa", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.18" + "source": "https://github.com/utopia-php/database/tree/0.53.19" }, - "time": "2024-11-08T04:02:13+00:00" + "time": "2024-11-08T07:00:24+00:00" }, { "name": "utopia-php/domains", @@ -2542,16 +2542,16 @@ }, { "name": "utopia-php/queue", - "version": "0.7.1", + "version": "0.7.2", "source": { "type": "git", "url": "https://github.com/utopia-php/queue.git", - "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8" + "reference": "40fdd9799d0a11dd33fca06f8223032a47dce2f6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/queue/zipball/94c240d9f6383829807ce7b2d737f04b159fd3e8", - "reference": "94c240d9f6383829807ce7b2d737f04b159fd3e8", + "url": "https://api.github.com/repos/utopia-php/queue/zipball/40fdd9799d0a11dd33fca06f8223032a47dce2f6", + "reference": "40fdd9799d0a11dd33fca06f8223032a47dce2f6", "shasum": "" }, "require": { @@ -2597,9 +2597,9 @@ ], "support": { "issues": "https://github.com/utopia-php/queue/issues", - "source": "https://github.com/utopia-php/queue/tree/0.7.1" + "source": "https://github.com/utopia-php/queue/tree/0.7.2" }, - "time": "2024-11-05T17:00:38+00:00" + "time": "2024-11-11T10:04:02+00:00" }, { "name": "utopia-php/registry", @@ -7052,7 +7052,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { From 8cca88f2b8180944e0fb2a8170d431047de0805c Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 11 Nov 2024 18:52:15 +0200 Subject: [PATCH 13/22] Remove Sentry comment --- src/Appwrite/Platform/Workers/Databases.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Databases.php b/src/Appwrite/Platform/Workers/Databases.php index accc003976..fe81114ea0 100644 --- a/src/Appwrite/Platform/Workers/Databases.php +++ b/src/Appwrite/Platform/Workers/Databases.php @@ -193,7 +193,6 @@ class Databases extends Action ); } - // TODO: Send non DatabaseExceptions to Sentry throw $e; } finally { $this->trigger($database, $collection, $attribute, $project, $projectId, $events); @@ -298,7 +297,6 @@ class Databases extends Action ); } - // TODO: Send non DatabaseExceptions to Sentry throw $e; } finally { $this->trigger($database, $collection, $attribute, $project, $projectId, $events); @@ -419,7 +417,6 @@ class Databases extends Action $index->setAttribute('status', 'failed') ); - // TODO: Send non DatabaseExceptions to Sentry throw $e; } finally { $this->trigger($database, $collection, $index, $project, $projectId, $events); From 33037a3ae588d690d180b9480fff1738fe428019 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 13:34:40 +1300 Subject: [PATCH 14/22] Update database --- app/controllers/api/databases.php | 3 ++- composer.json | 2 +- composer.lock | 38 +++++++++++++++---------------- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 0114fd343c..c1d7e8d11a 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2627,7 +2627,8 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/indexes') $validator = new IndexValidator( $collection->getAttribute('attributes'), - $dbForProject->getAdapter()->getMaxIndexLength() + $dbForProject->getAdapter()->getMaxIndexLength(), + $dbForProject->getAdapter()->getInternalIndexesKeys(), ); if (!$validator->isValid($index)) { throw new Exception(Exception::INDEX_INVALID, $validator->getDescription()); diff --git a/composer.json b/composer.json index b82e4a55a3..c11f78757b 100644 --- a/composer.json +++ b/composer.json @@ -51,7 +51,7 @@ "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.53.19", + "utopia-php/database": "0.53.20", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index c01ce6545e..e47c49af78 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": "73a05899db73e80a2b9c66dbbfb8562e", + "content-hash": "217b0c1b6c156d51bf5a2674f87a7630", "packages": [ { "name": "adhocore/jwt", @@ -1770,16 +1770,16 @@ }, { "name": "utopia-php/database", - "version": "0.53.19", + "version": "0.53.20", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "48951885f2787df30ad8581a0e94423558619daa" + "reference": "e43f8ee26e06ee8812737e63642dbd7ee7c9dc04" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/48951885f2787df30ad8581a0e94423558619daa", - "reference": "48951885f2787df30ad8581a0e94423558619daa", + "url": "https://api.github.com/repos/utopia-php/database/zipball/e43f8ee26e06ee8812737e63642dbd7ee7c9dc04", + "reference": "e43f8ee26e06ee8812737e63642dbd7ee7c9dc04", "shasum": "" }, "require": { @@ -1820,9 +1820,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.53.19" + "source": "https://github.com/utopia-php/database/tree/0.53.20" }, - "time": "2024-11-08T07:00:24+00:00" + "time": "2024-11-12T00:23:36+00:00" }, { "name": "utopia-php/domains", @@ -2222,16 +2222,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.11", + "version": "0.6.12", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "4d167914d3f7fa1fe816b2b2c6f221e70166bfd7" + "reference": "9a8c905af4cece5c5ec9542a5b534befce067260" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/4d167914d3f7fa1fe816b2b2c6f221e70166bfd7", - "reference": "4d167914d3f7fa1fe816b2b2c6f221e70166bfd7", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/9a8c905af4cece5c5ec9542a5b534befce067260", + "reference": "9a8c905af4cece5c5ec9542a5b534befce067260", "shasum": "" }, "require": { @@ -2272,9 +2272,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.11" + "source": "https://github.com/utopia-php/migration/tree/0.6.12" }, - "time": "2024-10-31T06:19:57+00:00" + "time": "2024-11-12T00:31:53+00:00" }, { "name": "utopia-php/mongo", @@ -2817,16 +2817,16 @@ }, { "name": "utopia-php/vcs", - "version": "0.8.3", + "version": "0.8.5", "source": { "type": "git", "url": "https://github.com/utopia-php/vcs.git", - "reference": "a032ed0611a8f4467aeaa9484f73223074457337" + "reference": "7622330628d53844a3873ca873338150756bab82" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/vcs/zipball/a032ed0611a8f4467aeaa9484f73223074457337", - "reference": "a032ed0611a8f4467aeaa9484f73223074457337", + "url": "https://api.github.com/repos/utopia-php/vcs/zipball/7622330628d53844a3873ca873338150756bab82", + "reference": "7622330628d53844a3873ca873338150756bab82", "shasum": "" }, "require": { @@ -2860,9 +2860,9 @@ ], "support": { "issues": "https://github.com/utopia-php/vcs/issues", - "source": "https://github.com/utopia-php/vcs/tree/0.8.3" + "source": "https://github.com/utopia-php/vcs/tree/0.8.5" }, - "time": "2024-11-05T17:10:09+00:00" + "time": "2024-11-11T18:33:10+00:00" }, { "name": "utopia-php/websocket", From c1a3b29a978a7ef0820e500d5c6b77da13b79ed6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 14:37:03 +1300 Subject: [PATCH 15/22] Temp test all shared tables versions --- .github/workflows/tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 29aa9b0581..2c1f3dadf5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -148,7 +148,10 @@ jobs: - name: Run ${{matrix.service}} Tests run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - - name: Run ${{matrix.service}} Shared Tables Tests + - name: Run ${{matrix.service}} Shared Tables V1 Tests + run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug + + - name: Run ${{matrix.service}} Shared Tables V2 Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug benchmarking: From 3b19ef6b1e3bb3671b754dc8fd2ae0ec0a80c627 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 15:00:23 +1300 Subject: [PATCH 16/22] Remove V2 tests --- .github/workflows/tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2c1f3dadf5..e13f4cd705 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -151,9 +151,6 @@ jobs: - name: Run ${{matrix.service}} Shared Tables V1 Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - - name: Run ${{matrix.service}} Shared Tables V2 Tests - run: _APP_DATABASE_SHARED_TABLES=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - benchmarking: name: Benchmark runs-on: ubuntu-latest From e626c2ad450919e7d5335eb6c5884e47bf579000 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 19:14:46 +1300 Subject: [PATCH 17/22] Run in all table modes in parallel --- .github/workflows/tests.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e13f4cd705..5384c0b5f0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -127,6 +127,11 @@ jobs: Messaging, Migrations ] + tables-mode: [ + Project, + Shared-V1, + Shared-V2, + ] steps: - name: checkout @@ -145,8 +150,11 @@ jobs: docker compose up -d sleep 30 - - name: Run ${{matrix.service}} Tests - run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug + - name: Run ${{ matrix.service }} tests with ${{ matrix.tables-mode }} table mode + run: docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{ matrix.service }} --debug + env: + _APP_DATABASE_SHARED_TABLES: ${{ matrix.table_mode == 'Shared V1' || matrix.table_mode == 'Shared V2' && 'database_db_main' || '' }} + _APP_DATABASE_SHARED_TABLES_V1: ${{ matrix.table_mode == 'Shared V1' && 'database_db_main' || '' }} - name: Run ${{matrix.service}} Shared Tables V1 Tests run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug From f6ea6d2fc560884a0aa04128e7b861996adb5886 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 19:15:33 +1300 Subject: [PATCH 18/22] Fix matrix --- .github/workflows/tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5384c0b5f0..6b965882fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -128,9 +128,9 @@ jobs: Migrations ] tables-mode: [ - Project, - Shared-V1, - Shared-V2, + 'Project', + 'Shared V1', + 'Shared V2', ] steps: From e715f9e90c279da518c116d69671515051a393fd Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 12 Nov 2024 20:52:25 +1300 Subject: [PATCH 19/22] Remove redundant V1 tests --- .github/workflows/tests.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6b965882fa..29b3bdd70d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -156,9 +156,6 @@ jobs: _APP_DATABASE_SHARED_TABLES: ${{ matrix.table_mode == 'Shared V1' || matrix.table_mode == 'Shared V2' && 'database_db_main' || '' }} _APP_DATABASE_SHARED_TABLES_V1: ${{ matrix.table_mode == 'Shared V1' && 'database_db_main' || '' }} - - name: Run ${{matrix.service}} Shared Tables V1 Tests - run: _APP_DATABASE_SHARED_TABLES=database_db_main _APP_DATABASE_SHARED_TABLES_V1=database_db_main docker compose exec -T appwrite test /usr/src/code/tests/e2e/Services/${{matrix.service}} --debug - benchmarking: name: Benchmark runs-on: ubuntu-latest From 6e7dd26f75449cfa21ff0615f364493b717f7126 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 12 Nov 2024 12:37:15 +0100 Subject: [PATCH 20/22] feat: fix web routes --- app/controllers/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index 663242882a..b036539860 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -438,7 +438,7 @@ App::init() }); App::init() - ->groups(['api', 'web']) + ->groups(['api']) ->inject('utopia') ->inject('swooleRequest') ->inject('request') From dad8f597cae42dda827cf7f702dcbf762066d696 Mon Sep 17 00:00:00 2001 From: loks0n <22452787+loks0n@users.noreply.github.com> Date: Tue, 12 Nov 2024 16:05:51 +0100 Subject: [PATCH 21/22] debug: whitelist console --- app/controllers/general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/general.php b/app/controllers/general.php index b036539860..26e052fe50 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -63,7 +63,7 @@ function router(App $utopia, Database $dbForConsole, callable $getProjectDB, Swo } if (System::getEnv('_APP_OPTIONS_ROUTER_PROTECTION', 'disabled') === 'enabled') { - if ($host !== 'localhost' && $host !== APP_HOSTNAME_INTERNAL) { // localhost allowed for proxy, APP_HOSTNAME_INTERNAL allowed for migrations + if ($host !== 'localhost' && $host !== APP_HOSTNAME_INTERNAL && $host !== System::getEnv('_APP_CONSOLE_DOMAIN', '')) { throw new AppwriteException(AppwriteException::GENERAL_ACCESS_FORBIDDEN, 'Router protection does not allow accessing Appwrite over this domain. Please add it as custom domain to your project or disable _APP_OPTIONS_ROUTER_PROTECTION environment variable.'); } } From 900f64bf8ddf2bdf0d475ebca83409572ba0e7ca Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 12 Nov 2024 18:00:38 +0100 Subject: [PATCH 22/22] feat: hack for multi region --- app/controllers/api/projects.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 39300a2d4a..483ebdd7b4 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -136,6 +136,16 @@ App::post('/v1/projects') $dsn = $databases[array_rand($databases)]; } + $dsns = [ + 'fra' => 'database_db_fra1_self_hosted_0_0', + 'syd' => 'database_db_syd1_self_hosted_0_0', + 'nyc' => 'database_db_nyc1_self_hosted_0_0', + ]; + + if (isset($dsns[$region])) { + $dsn = $dsns[$region]; + } + // TODO: Temporary until all projects are using shared tables. $sharedTables = \explode(',', System::getEnv('_APP_DATABASE_SHARED_TABLES', ''));