As seen in this thread: http://groups.google.com/group/web2py/browse_thread/thread/c6653dadbea77f0d/06ed6fe085eae33c
I'm getting "broken pipe" messages when mysql is restarted, and under other circunstances. Going to a shell, I tried doing a query, for example: >>> db(db.location).select() <gluon.dal.Rows object at 0xa2056ec> everything goes ok. Then I restart Mysql, and running the same query I get: >>> db(db.location).select() Traceback (most recent call last): File "<console>", line 1, in <module> File "/var/www/web2py_klnetcenter/gluon/dal.py", line 5382, in select return self.db._adapter.select(self.query,fields,attributes) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1159, in select rows = response(sql) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1149, in response self.execute(sql) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1234, in execute return self.log_execute(*a, **b) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1229, in log_execute ret = self.cursor.execute(*a,**b) File "/var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py", line 108, in execute self.errorhandler(self, exc, value) File "/var/www/web2py_klnetcenter/gluon/contrib/pymysql/ connections.py", line 184, in defaulterrorhandler raise errorclass, errorvalue OperationalError: (2013, 'Lost connection to MySQL server during query') trying to run it again, I only get: >>> db(db.location).select() Traceback (most recent call last): File "<console>", line 1, in <module> File "/var/www/web2py_klnetcenter/gluon/dal.py", line 5382, in select return self.db._adapter.select(self.query,fields,attributes) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1159, in select rows = response(sql) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1149, in response self.execute(sql) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1234, in execute return self.log_execute(*a, **b) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1229, in log_execute ret = self.cursor.execute(*a,**b) File "/var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py", line 108, in execute self.errorhandler(self, exc, value) File "/var/www/web2py_klnetcenter/gluon/contrib/pymysql/ connections.py", line 182, in defaulterrorhandler raise Error(errorclass, errorvalue) Error: (<class 'socket.error'>, error(32, 'Broken pipe')) forever!. However, if I do: >>> db._adapter.connection.ping() True >>> db(db.location).select() <gluon.dal.Rows object at 0xa20596c> so it looks like pinging does a reconnect. If the connection is closed manually, it won't reconnect either: >>> db(db.location).select() <gluon.dal.Rows object at 0xa205a0c> >>> db._adapter.connection.close() >>> print db(db.location).select() Traceback (most recent call last): File "<console>", line 1, in <module> File "/var/www/web2py_klnetcenter/gluon/dal.py", line 5382, in select return self.db._adapter.select(self.query,fields,attributes) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1159, in select rows = response(sql) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1149, in response self.execute(sql) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1234, in execute return self.log_execute(*a, **b) File "/var/www/web2py_klnetcenter/gluon/dal.py", line 1229, in log_execute ret = self.cursor.execute(*a,**b) File "/var/www/web2py_klnetcenter/gluon/contrib/pymysql/cursors.py", line 108, in execute self.errorhandler(self, exc, value) File "/var/www/web2py_klnetcenter/gluon/contrib/pymysql/ connections.py", line 184, in defaulterrorhandler raise errorclass, errorvalue InterfaceError: (0, '') forever again! Is this the expected behavior? Is web2py or the adapter not detecting it is not connected and not trying to reconnect unless you ping the connection? I think this needs fixing. I have a long running shell process, and every night I find it stopped working and "broken pipe" errors are all around... I'm trying to workaround it pinging the connection, but I think that's not a good fix... Greets.