appwrite: πŸ› Bug Report: [1.4.X - 1.5.X] Function throws MySQL server has gone away

πŸ‘Ÿ Reproduction steps

Sometimes, when I try to call a function from Appwrite, I got the error :

flutter: AppwriteException: general_unknown, Server Error (500)

When I try to check on Appwrite, the function was not called at all, there is no failing execution in the execution list…

I looked into docker logs appwrite right after this issue & get this strange log:

[Error] Timestamp: 2024-04-07T09:12:42+00:00
[Error] Method: POST
[Error] URL: /v1/functions/:functionId/executions
[Error] Type: PDOException
[Error] Message: MySQL server has gone away
[Error] File: @swoole-src/library/core/Database/PDOStatementProxy.php
[Error] Line: 62

I ran docker logs appwrite-mariadb and I get:

[...]
2024-04-07  2:56:25 133 [Warning] Aborted connection 133 to db: 'appwrite' user: 'user' host: '172.20.0.14' (Got timeout reading communication packets)
2024-04-07  2:57:41 134 [Warning] Aborted connection 134 to db: 'appwrite' user: 'user' host: '172.20.0.14' (Got timeout reading communication packets)
2024-04-07  3:35:37 135 [Warning] Aborted connection 135 to db: 'appwrite' user: 'user' host: '172.20.0.14' (Got timeout reading communication packets)
2024-04-07  3:36:04 128 [Warning] Aborted connection 128 to db: 'appwrite' user: 'user' host: '172.20.0.11' (Got timeout reading communication packets)
2024-04-07  3:36:04 131 [Warning] Aborted connection 131 to db: 'appwrite' user: 'user' host: '172.20.0.12' (Got timeout reading communication packets)
2024-04-07  6:00:03 129 [Warning] Aborted connection 129 to db: 'appwrite' user: 'user' host: '172.20.0.14' (Got timeout reading communication packets)

πŸ‘ Expected behavior

It should execute all functions without error

πŸ‘Ž Actual Behavior

Sometimes function throw error 500

🎲 Appwrite version

Version 1.4.x

πŸ’» Operating system

Linux

🧱 Your Environment

I use an Hetzner instance

πŸ‘€ Have you spent some time to check if this issue has been raised before?

  • I checked and didn’t find similar issue

🏒 Have you read the Code of Conduct?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 15 (1 by maintainers)

Most upvoted comments

I updated my instance to version 1.5.4 and since then I haven’t had any recurrence. However, I’ll have to test it further, as I haven’t had time to use appwrite much. But this is already very encouraging πŸ‘

@istornz Thank you for this valuable information. πŸ‘

@Emilien-Lambert, after conducting some investigations, I believe there’s a bug related to 1.4.X statistics.

Why?

  • There is a known issue with 1.4.X statistics. This feature is broken in that version and can display negative values on the UI.
  • When performing actions like deleting a user or triggering a function, Appwrite attempts to modify stats (such as adding a function execution or incrementing/decrementing user counts).
  • In my case, the function is a simple HTTP call and does not interact with the Appwrite database, so it’s not related to the function itself.

Appwrite 1.5.X completely overhauls the statistics system. I upgraded my instance to 1.5.4 yesterday, and so far, it appears to be much improved. I haven’t encountered this error since the upgrade (wish me lucks :p).

As a temporary workaround, consider the following:

  • Disable statistics by setting _APP_USAGE_STATS to false (not tested, but it should works?).
  • Upgrade to 1.5.X.

Please note that this is purely speculative on my part. 😊

Any advice of Appwrite team like @stnguyen90 or @Meldiron would be great πŸ‘