MySQL and InfluxDB timeouts

I run a web.py server on my machine, which constantly receives POST data and stores some data in MySQL (5.7.19) and some in InfluxDB (1.3.1) hosted on a remote server running Ubuntu (16.04.1).

I also have a Python script running locally, fetching InfluxDB data and manipulating MySQL data. This python script creates new connections to both bases every time its main function starts (closing them also every time), which can be up to 10 times per second. I am using MySQLdb and InfluxDB Python APIs.

The problem is that after a while, I periodically get connection timeouts to both databases.

This is what the error messages look like:

MySQL: OperationalError: (1205, "Lock wait timeout exceeded, please try reloading transaction ')

InfluxDB: InfluxDBServerError: {"error": "timeout"}

After thoroughly examining all of my code, I cannot find the cause of this problem. Does MySQL and Influx, or maybe even Ubuntu have a connection limit per user and time?

When it comes to MySQL, some rows are locked using a SELECT FOR UPDATE query, but in the code, all transactions are either fixed or rolled back. If the connection is lost before committing or rolling back, this explains the MySQL timeouts, as it will try to access the locked row that will not be unlocked properly.

When it comes to InfluxDB, we're just dealing with atomic inserts which don't make any sense to me.

If anyone knows what might be causing these timeouts, I'd be eternally grateful!

+3


source to share





All Articles