Rank 1: Thread
I encountered what is hopefully a super rare bug over the weekend and had a doozy of a time finding the solution to it. I'd like to document the issue and solution for anyone else who might run into something similar, as well as let the Appwrite team know in case it points to a deeper problem.
The problem: Over the weekend, I noticed that my server had randomly crashed while several users were testing different functionality, and was able to tie it to function executions. That is, whenever a serverless function was being executed, it would result in a 500 error that necessitated a full restart.
The investigation: After diving into the debugging rabbit hole, I found some promising logs in the mariadb:10.7 container.
The logs indicate an assertion failure inside the MariaDB server. In the context of MariaDB, this usually indicates a bug in the server, potential database corruption, or a problematic query.
The specific error message is: InnoDB: Assertion failure in file /home/buildbot/buildbot/build/mariadb-10.7.5/storage/innobase/que/que0que.cc line 728. This is followed by a message related to a duplicate key on an FTS auxiliary index table (appwrite._1_executions).
The solution: After backing up my server and database, I decided to re-index the appwrite._1_executions table via a suggestion from GPT-4. So, I dropped and recreated all of the indices. This did indeed turn out to be the necessary fix.
My question: Does this point towards an issue with execution queuing whereby multiple functions being queued to execute at the same time could result in a duplication of keys in the executions table? This type of thing SHOULD be an atomic operation by the very nature of SQL databases, but I suppose might occur if the execution queue was handled manually. I'll add some extra helpful information about my setup in particular for more context in my next message (as I'm running out of message space here).
