#Random 500s while deleting documents with relationship

10 messages · Page 1 of 1 (latest)

spice shoal
#

Hey, new report of 500 errors related to relationships.

I have collection A with two one-way one-to-many relationship fields to collection B.

I loop over documents and delete them using databases.deleteDocument.

  1. When both of the fields contain no document, I get a 500 error and this error:
[Error] Method: DELETE
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
[Error] Type: PDOException
[Error] Message: There is already an active transaction
[Error] File: @swoole-src/library/core/Database/PDOProxy.php
[Error] Line: 43
  1. When one of the two fields is not empty (so it still has at least one relationship), I have this error:
[Error] Method: DELETE
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
[Error] Type: Exception
[Error] Message: Unknown PDO Type for object
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Adapter/MariaDB.php
[Error] Line: 1347

I love Appwrite, but all these errors are ruining our 3 apps in production, so we have to stop using Appwrite for the next developments.
These 3 apps are totally independent and all using 1.3.7. All have quite large amount of data (>50k documents with relationships) and traffic (100s of daily users).

Looking at other similar posts, it seems you've never replicated these kind of errors on your side, maybe we should organize to make sure it can be tracked?
@trail heron suggested to create some sort of tracking for these relationship-related errors, I think it's a good idea.

#

If you have some development power available on your side, I can suggest you to create a demo project with real-life amount of data + activity using extensive relationship so you can identify the issues.
Most of issues I have identified for now are happening on document update and deletion.
Also one very annoying permission issue when using two collections with document-security enabled.

#
GitHub

👟 Reproduction steps I have two collections with following attributes: task: title project (one way, many to one, On delete set null) project: title If I now try to delete a document that has a rel...

jagged palm
#

If you could send here and in the issue the related docker errors, could be really helpful

#

I recommend using sentry to log errors

spice shoal
spice shoal
#

Btw there is also a 500 error when updating only one field of a document without updating its relationships.
For example:

{ '$id': 'abc',  '$collectionId': 'a', 'profiles': [{ '$id': 'xyz', '$collectionId': 'b' }] }, 'name': 'John'}

databases.updateDocument('db', 'a', 'abc', { name: 'Hello' }) // throws a 500 error
databases.updateDocument('db', 'a', 'abc', { name: 'Hello', profiles: [{$id: 'xyz', ...}] }) // throws a 500 error
databases.updateDocument('db', 'a', 'abc', { name: 'Hello', profiles: ['xyz'] }) // doesn't throw error

It yields this 500 error:

[Error] Method: PATCH
[Error] URL: /v1/databases/:databaseId/collections/:collectionId/documents/:documentId
[Error] Type: Exception
[Error] Message: Invalid value for relationship
[Error] File: /usr/src/code/vendor/utopia-php/database/src/Database/Database.php
[Error] Line: 3099
jagged palm
wary fractal