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

Fix/silence SQLite log messages at first launch #6295

Closed
friedbunny opened this issue Sep 8, 2016 · 6 comments
Closed

Fix/silence SQLite log messages at first launch #6295

friedbunny opened this issue Sep 8, 2016 · 6 comments
Labels
Core The cross-platform C++ core, aka mbgl

Comments

@friedbunny
Copy link
Contributor

friedbunny commented Sep 8, 2016

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

@friedbunny friedbunny added the Core The cross-platform C++ core, aka mbgl label Sep 8, 2016
@jfirebaugh
Copy link
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?

@jfirebaugh
Copy link
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.

@friedbunny
Copy link
Contributor Author

@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)

@friedbunny
Copy link
Contributor Author

friedbunny commented Sep 8, 2016

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.

@jfirebaugh
Copy link
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.

@kkaefer
Copy link
Member

kkaefer commented Aug 15, 2018

This was fixed in #11865

@kkaefer kkaefer closed this as completed Aug 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl
Projects
None yet
Development

No branches or pull requests

3 participants