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.

Fix/silence SQLite log messages at first launch #6295

Closed

Description

@friedbunny

The new SQLite logging from #6291 now shows us a few messages on database creation. We should decide if these represent bugs or just messages that we can silence.

iOS (simulator):

[INFO] {DefaultFileSource}[Database]: cannot open file at line 38073 of [91e811f51e] (Code 14)
[INFO] {DefaultFileSource}[Database]: [91e811f51e]:38073: (3) open(/Library/Developer/CoreSimulator/Devices/.../com.mapbox.MapboxGL/.mapbox/cache.db) -  (Code 14)
[INFO] {DefaultFileSource}[Database]: misuse at line 141285 of [91e811f51e] (Code 21)
[INFO] {DefaultFileSource}[Database]: misuse at line 141285 of [91e811f51e] (Code 21)

Android (emulator):

{DefaultFileSour}[Database]: cannot open file at line 32438 of [767c1727fe] (Code 14)
{DefaultFileSour}[Database]: os_unix.c:32438: (2) open(/data/user/0/com.mapbox.mapboxsdk.testapp/files/mbgl-offline.db) - No such file or directory (Code 14)
{DefaultFileSour}[Database]: misuse at line 131142 of [767c1727fe] (Code 21)
{DefaultFileSour}[Database]: misuse at line 131142 of [767c1727fe] (Code 21)

/cc @jfirebaugh

Activity

  1. added
    Core
    on Sep 8, 2016
  2. jfirebaugh commented on Sep 8, 2016

    @jfirebaugh
    Contributor

    SQLITE_MISUSE sounds like we could be doing something we shouldn't.

    Do you have any idea what the magic numbers like 141285 and 91e811f51e refer to?

  3. jfirebaugh commented on Sep 8, 2016

    @jfirebaugh
    Contributor

    I set a breakpoint inside errorLogCallback, and can see that SQLITE_MISUSE is coming from the second call to sqlite3_config. I think we're failing to obey this part of the documentation:

    The sqlite3_config() interface may only be invoked prior to library initialization using sqlite3_initialize() or after shutdown by sqlite3_shutdown(). If sqlite3_config() is called after sqlite3_initialize() and before sqlite3_shutdown() then it will return SQLITE_MISUSE.

    We could fix this by moving the sqlite3_config call into the sqliteVersionCheck static initializer above, so it only runs once, at startup.

  4. friedbunny commented on Sep 8, 2016

    @friedbunny
    ContributorAuthor

    @jfirebaugh Moving the log setting to sqliteVersionCheck does indeed work, thanks for the suggestion. I’ve put in #6296 along those lines.

    Do you have any idea what the magic numbers like 141285 and 91e811f51e refer to?

    No, I have no idea what those are — will have to dig into the SQLite docs if this becomes an issue again.

    A side-effect of enabling SQLite logging is that we also see errors from other databases within our process, like this one from NSURLSession that occurred after I had paused execution:

    [ERROR] {}[Database]: no such table: cfurl_cache_response (Code 1)
    
  5. friedbunny commented on Sep 8, 2016

    @friedbunny
    ContributorAuthor

    I also looked into suppressing SQLITE_CANTOPEN, but that would mean we wouldn’t see important messages like #6193 (comment).

    We will need to find a way to isolate this benign first launch SQLITE_CANTOPEN from meaningful occurrences.

  6. jfirebaugh commented on Sep 8, 2016

    @jfirebaugh
    Contributor

    A side-effect of enabling SQLite logging is that we also see errors from other databases within our process, like this one from NSURLSession that occurred after I had paused execution:

    Oh, hmm, that points to a problem. What if the app embedding the SDK expects to be able to set its own logging callback? It's a race to who can set it first, our code or their code.

  7. kkaefer commented on Aug 15, 2018

    @kkaefer
    Member

    This was fixed in #11865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions