Back

Random 500s while deleting documents with relationship

  • 0
  • Databases
42Tom
19 Jul, 2023, 23:04

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:
TypeScript
[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:
TypeScript
[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? @Vedsaga suggested to create some sort of tracking for these relationship-related errors, I think it's a good idea.

TL;DR
TL;DR: Users are experiencing random 500 errors when deleting documents with relationships in Appwrite. There are also 500 errors when updating documents with relationships. Some suggested solutions include creating a GitHub issue for each reproducible problem and using Sentry for error logging. The errors are causing issues for production apps and the user suggests creating a tracking system to resolve the errors.
42Tom
19 Jul, 2023, 23:09

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.

D5
19 Jul, 2023, 23:21

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

D5
19 Jul, 2023, 23:21

I recommend using sentry to log errors

42Tom
19 Jul, 2023, 23:22

Sure, which docker container?

42Tom
19 Jul, 2023, 23:23

How does it work with Appwrite?

42Tom
19 Jul, 2023, 23:37

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

TypeScript
{ '$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:

TypeScript
[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
D5
19 Jul, 2023, 23:43

You set the env var and then you get all errors from all containers and very detailed (more than the ones Appwrite gives you)

Drake
19 Jul, 2023, 23:59

for tracking, a github issue per reproducible problem would be best. The most important part is we need to be able to reproduce it so that we can figure out what's wrong and fix it

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more