Hi list, my team develops a relatively long-running (normally 10+ hours, during development for days or even weeks) Qt application that uses a MySQL database.
The usage pattern the database connection looks like this: At startup: - db = QSqlDatabase::addDatabase(connection_name) - configure host, user, password, etc. - db.open() to verify that the connection works. Throughout the runtime: - db = QSqlDatabase::database(connection_name) - QSqlQuery(db) ... At shutdown: - QSqlDatabase::removeDatabase(connection_name) 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. My theory is that the initial QSqlDatabase::open() creates a connection to the SQL server that is kept open permanently by the QSqlDatabase instance that Qt keeps internally (in the ConnectionDict) that references the same connection. The SQL server eventually closes the connection after some timeout, which the application doesn't notice until it tries to use the connection again. Now my questions: - Is the usage pattern I described above basically correct, or should we do something differently? - Does my theory sound reasonable? - Does anybody know something we could do to avoid the error? Thanks in advance. -- 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.schmit...@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. +++ _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest