Thanks for pointing this out Łukasz, I created a change to disable useless mutexes on sqlite db connection : https://codereview.qt-project.org/#/c/185835/ Unfortunately that would break your usage, but it seems like it is already broken as Lorenz explained. All db intensive usage should see a perfromance win.
Eric Le jeu. 16 févr. 2017 à 07:37, Samuel Nevala <[email protected]> a écrit : > Hi, > > Just recently needed to fix threading issues with SQLite on > non-Qt-context. Here here is obsolete information that helped me:). > http://www.sqlite.org/cvstrac/wiki?p=MultiThreading. From that doc: "By > "threadsafe" we mean that you can use different SQLite database connections > in different threads at the same time. It has never been safe to use the > same database connection simultaneously in multiple threads." > > Samuel > > On 15 February 2017 at 21:24, Lorenz Haas <[email protected]> wrote: > > Hi, > > AFAIS it does not matter if sqlite is thread safe or not. The problem is > that QSQLiteDriver itself is not thread safe. For example if two threads > call beginTransaction() on the same driver and the "COMMIT" fails, both > threads will call QSqlDriver::setLastError() which does "d->error = > error;". And here is the first problem. > > I am not an expert with QSqlQuery, but since it uses the driver, I bet, > you'll also find UB and races there. > > Cheers > Lorenz > > Am 15.02.2017 um 13:37 schrieb Łukasz Korbel: > > According to > > http://doc.qt.io/qt-5/threads-modules.html#threads-and-the-sql-module > > database connection should be used within one thread *only*. > > > > I have checked SQLite driver and according to > > https://www.sqlite.org/threadsafe.html it supports multithreading by > > default. And it seems that Qt implementation does not restrict it > > ( > http://code.qt.io/cgit/qt/qtbase.git/tree/src/plugins/sqldrivers/sqlite/qsql_sqlite.cpp#n645 > ). > > Code I'm working on is creating QSqlQuery for the same connection in > > different threads and it works. > > > > I understand it doesn't mean Qt want or need to support such use case > > but maybe documentation > > can be slightly more accurate? Right now it implies that database > > connection can never be used from different threads but it seem it > > depends more on particular driver/3rdparty lib. > > > > > > *Łukasz Korbel * > > Senior Software Developer > > Email: [email protected] > > Skype: lukasz_korbel > > *Milo Solutions* > > www.milosolutions.com <http://www.milosolutions.com> | Facebook > > <https://www.facebook.com/theMiloSolutions> | Twitter > > <https://twitter.com/milosolutions> > > Disclaimer: This e-mail and any attachments contain information that may > > be privileged or confidential and is the property of Milo Solutions. If > > you are not the intended recipient, please notify me immediately by > > replying to this e-mail, and then delete it. Any unauthorised > > dissemination, distribution, copying or use of this communication is > > strictly prohibited. The contents of an attachment to this e-mail may > > contain software viruses, which could damage your own computer system. > > Although this e-mail and any files attached to it may have been checked > > with virus detection software before transmission you should carry out > > your own virus checks before opening the attachment. No liability can be > > accepted for any damage which you may sustain as a result of software > > viruses. > > > > > > > > _______________________________________________ > > Development mailing list > > [email protected] > > http://lists.qt-project.org/mailman/listinfo/development > > > _______________________________________________ > Development mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/development > > > _______________________________________________ > Development mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/development >
_______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
