Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

[Qt] "database is locked" when opening the same db in different threads #9108

Closed

Description

@brunoabinader

Got this on CircleCI with parallel execution:

[ RUN      ] OfflineDatabase.ConcurrentUse
[WARNING] {memcheck-amd64-}[Database]: Removing existing incompatible offline database
terminate called after throwing an instance of 'mapbox::sqlite::Exception'
  what():  database is locked Unable to fetch row

Activity

  1. added
    Qt
    on May 25, 2017
  2. brunoabinader commented on May 25, 2017

    @brunoabinader
    ContributorAuthor
  3. tmpsantos commented on May 29, 2017

    @tmpsantos
    Contributor

    We are not sharing the DefaultFileSource on Qt. We should do that by default, unless the user defines a path for the cache that is different from the default path, otherwise it would break the QtLocation plugin API.

  4. added a commit that references this issue on Jul 12, 2017
    5849b57
  5. added a commit that references this issue on Jul 13, 2017
    398320f
  6. added a commit that references this issue on Jul 13, 2017
    bb1a209
  7. self-assigned this
    on Jul 13, 2017
  8. tmpsantos commented on Jul 13, 2017

    @tmpsantos
    Contributor

    That test is wrong, not sure how it is working to be honest. The sqlite API is not thread safe unless we use SQLITE_OPEN_FULLMUTEX which we should not use.

  9. jfirebaugh commented on Jul 13, 2017

    @jfirebaugh
    Contributor

    The test is correct. We need sqlite in at least "multi-thread" mode, where multiple threads with independent connections are safe; that's what the test is testing.

    If the current Qt setup is operating in "single-thread" mode, then that needs to be fixed.

    We do not depend on "serialized" mode, but there's no harm if the sqlite implementation is in that mode.

    https://sqlite.org/threadsafe.html

  10. jfirebaugh commented on Jul 13, 2017

    @jfirebaugh
    Contributor

    The log message "Removing existing incompatible offline database" (OfflineDatabase::removeExisting()) may be the key here. I don't think that should be happening with this test.

  11. tmpsantos commented on Jul 13, 2017

    @tmpsantos
    Contributor

    @jfirebaugh thanks a lot for the new insight on this issue. I'm suspecting that QSqlDatabase can only do single-thread to keep compatibility across multiple platforms it supports. I will investigate the Qt source code further to reach a more solid conclusion.

  12. brunoabinader commented on Jul 14, 2017

    @brunoabinader
    ContributorAuthor

    Qt Sqlite plugin for QSqlDatabase does not allow setting e.g. SQLITE_OPEN_FULLMUTEX when opening the connection: https://doc.qt.io/qt-5/qsqldatabase.html#setConnectOptions

  13. tmpsantos commented on Jul 25, 2017

    @tmpsantos
    Contributor

    I think I finally found the issue. The busy timeout we set in mapboxgl is overflowing in Qt (signed -> unsigned) and for some reason Qt silently ignores the error, leaving the default timeout that is very low.

  14. added a commit that references this issue on Jul 26, 2017
    fe2a3f6
  15. added a commit that references this issue on Jul 26, 2017
    55faa23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Qtbugoffline

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions