QSqlQuery::exec() freezes over OpenVPN
-
@petar
Your application will not freeze due to Thread.
You know the integrity of your code. -
@petar said in QSqlQuery::exec() freezes over OpenVPN:
Aren't those drivers a part of Qt (eg. QPSQL for Postgres), it's not external driver.
Those use client libraries provided by the SQL database system like libmysqlclient for MySQL. To see whether this is an issue in Qt or database system you can try to execute exactly the same query over VPN with the client application of your database system.
-
@petar said in QSqlQuery::exec() freezes over OpenVPN:
Aren't those drivers a part of Qt (eg. QPSQL for Postgres), it's not external driver.
Those use client libraries provided by the SQL database system like libmysqlclient for MySQL. To see whether this is an issue in Qt or database system you can try to execute exactly the same query over VPN with the client application of your database system.
-
I tested it and it turns out it freezes even in non GUI applications, so it doesn't have to do anything with the GUI thing.
I just started QSqlQuery::exec() in non GUI app and it freezes forever over OpenVPN, while the same code works ok over LAN or on localhost. On LAN sometimes QSqlQuery::exec() returns false which is ok, but never freezes forever.
-
@A-A-SEZEN
Can I use thread for queries working with QSqlQuery and QSqlQueryModel? I am not sure. What about sharing connections (that is not allowed) between threads, and sharing queries?@petar said in QSqlQuery::exec() freezes over OpenVPN:
Can I use thread for queries working with QSqlQuery and QSqlQueryModel? I am not sure. What about sharing connections (that is not allowed) between threads, and sharing queries?
The codes above are thread codes I've tried for you.
I've already shared critical parts. The rest are standard thread class and database connections. It is up to you how much you can use within the integrity of your code.
SQLite does not allow concurrent operations to the same table. Other than that, you will have no problems. You can create a new SQLite connection in a thread, or you can include your connection class in a thread class. I have used both cases. I like to manage it myself instead of the model. I am using QTableWidget instead of QTableView. So I can't comment much on your situation.
Regards. -
I tested it and it turns out it freezes even in non GUI applications, so it doesn't have to do anything with the GUI thing.
I just started QSqlQuery::exec() in non GUI app and it freezes forever over OpenVPN, while the same code works ok over LAN or on localhost. On LAN sometimes QSqlQuery::exec() returns false which is ok, but never freezes forever.
-
@jsulm
I've already done this but got the answer from Christian Ehrlicher that this is probably a bug inside the libpq Postgres lib and that there is nothing they can do about it (concerning Qt). -
@petar said in QSqlQuery::exec() freezes over OpenVPN:
Can I use thread for queries working with QSqlQuery and QSqlQueryModel? I am not sure. What about sharing connections (that is not allowed) between threads, and sharing queries?
The codes above are thread codes I've tried for you.
I've already shared critical parts. The rest are standard thread class and database connections. It is up to you how much you can use within the integrity of your code.
SQLite does not allow concurrent operations to the same table. Other than that, you will have no problems. You can create a new SQLite connection in a thread, or you can include your connection class in a thread class. I have used both cases. I like to manage it myself instead of the model. I am using QTableWidget instead of QTableView. So I can't comment much on your situation.
Regards.