[Interest] Long running application with database connection

Marc Schmitzer marc.schmitzer at richard-wolf.com
Wed Oct 9 15:47:16 CEST 2013


On 10/09/2013 12:27 PM, Marc Schmitzer wrote:
> While this works well most of the time, we occasionally have queries
> fail with "MySQL server has gone away" errors. We know that the mysqld
> process has indeed *not* gone away, and re-opening the connection works.

Ok, this appears to be caused by the wait_timeout option of the MySQL
server[1], which defaults to 8 hours.

If you are unwilling/unable to change the server config, there are at
least two ways of working around this:

1) Setting the "reconnect" option on the mysql connection.
Unfortunately, this is not supported by the Qt-API (not even
QSqlDatabase::setConnectOptions) and requires fetching the raw MYSQL*
handle from the QSqlDriver and using mysql_options() from libmysqlclient.

2) Since the wait_timeout is an *idle* timeout, the connection can
presumably be kept alive by making regular dummy queries.


[1]
http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_wait_timeout

-- 
Mit freundlichen Gruessen / Best regards

Marc Schmitzer

SW-Entwicklung ESWL / ESWT
Software development ESWL / ESWT

*****************************************************************

Richard Wolf GmbH

Pforzheimer Strasse 32

75438 Knittlingen

Tel.:         +49 7043 35-1107
Fax:          +49 7043 35-1255
Email:        marc.schmitzer at richard-wolf.com
Web:          http://www.richard-wolf.com

*****************************************************************
+++
Richard Wolf GmbH, Pforzheimer Strasse 32, 75438 Knittlingen
Managing Directors: Siegfried Karst, Juergen Pfab, Juergen Steinbeck. Trade Register: Mannheim HRB 510031
+++
Richard Wolf GmbH routinely monitors the content of e-mail sent and received via its network for the purposes of ensuring compliance with its policies and procedures. Richard Wolf GmbH is not responsible for any changes made to the message after it has been sent. Where opinions are expressed, they are not necessarily those of Richard Wolf GmbH. This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you are not the intended addressee, or the person responsible for delivering it to them, you may not copy, forward, disclose, or otherwise use it or any part of it in any way. To do so may be unlawful. If you receive this e-mail by mistake, please advise the sender immediately.
+++




More information about the Interest mailing list