I'm a recent fan of web2py, having adopted it for some major institutional projects in global agriculture. So far, so good - very happy - but I have a recurring curious low level database error which I'm not sure how to fix.
I've already tried trapping my web2py data model in a try... except block, inside a loop to retry the database connection (about 20 times, or so I think), but this doesn't seem to help. The database connection often works... it is just that when the MySQL connection is idle for too long, or when a fresh connection is requested for a new user session, something fails... DAL doesn't handle it. Here's the background: I'm running web2py in an NGINX server via uwsgi (which generally works fine - configured based on good advice online). However, this server runs within an Amazon Web Services (AWS) EC2 server and accesses a MySQL instance running non-locally as a AWS Relational Database (RDB) server. I'm using a DAL pool_size of 10. Here's the error message: Operational Error: (2013, 'Lost connection to MySQL server during query') Traceback (most recent call last): File "/opt/web2py/gluon/main.py", line 506, in wsgibase BaseAdapter.close_all_instances('commit') File "/opt/web2py/gluon/dal.py", line 373, in close_all_instances getattr(instance,action)() File "/opt/web2py/gluon/dal.py", line 1225, in commit return self.connection.commit() File "/opt/web2py/gluon/contrib/pymysql/connections.py", line 562, in commit self.errorhandler(None, exc, value) File "/opt/web2py/gluon/contrib/pymysql/connections.py", line 184, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (2013, 'Lost connection to MySQL server during query') I hope someone can suggest something here. Do I need to tweak some MySQL client parameter, or does someone have some advice about Amazon RDB usage practicalities in such a situation? Cheers Richard Bruskiewich Scientific Consultant, International Rice Research Institute (IRRI)