You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
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
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.
SQLITE_CANTOPEN (14) is expected because of how we fail-open the database on first launch.
[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)
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.
@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)
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.
Activity
jfirebaugh commentedon Sep 8, 2016
SQLITE_MISUSEsounds like we could be doing something we shouldn't.Do you have any idea what the magic numbers like
141285and91e811f51erefer to?jfirebaugh commentedon Sep 8, 2016
I set a breakpoint inside
errorLogCallback, and can see thatSQLITE_MISUSEis coming from the second call tosqlite3_config. I think we're failing to obey this part of the documentation:We could fix this by moving the
sqlite3_configcall into thesqliteVersionCheckstatic initializer above, so it only runs once, at startup.friedbunny commentedon Sep 8, 2016
@jfirebaugh Moving the log setting to
sqliteVersionCheckdoes indeed work, thanks for the suggestion. I’ve put in #6296 along those lines.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:
friedbunny commentedon 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_CANTOPENfrom meaningful occurrences.jfirebaugh commentedon Sep 8, 2016
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 commentedon Aug 15, 2018
This was fixed in #11865