Hi I am trying to write an Node + Express to provide REST services. Everything goes well when the application starts. However, after several hours, I got an error: \"code\":
In my Ubuntu I found out that the database had corrupted exactly at 10:02 am from the mysql logs. Exactly at the same time this error message started. So I restarted the Ubuntu.
After rebooting it still gave same error. Around the time when mysql server turned "ready" it started working. Maybe Mysqld took a couple of seconds to resolve crash or database corruption.
I was getting this error in my application as well, and ended up raising the amount of available memory to MySQL to fix it. How to set memory limit in my.cnf file
It was most likely related to having large transactions and running out of memory.
In my experience that problem was due to creating a connection directly (with mysqljs/mysql library, unsing createConnection()
) instead of using createPool()
that allows to run query()
and releases the connection automatically after execution (doing getConnection()
+ query()
+ release()
).
Without that the connection is not released and, at the next attempt to query, there happens the fatal error.
See Pooling Connections.