Crash when updating from 6.0.0 to 6.0.2 due to cache database locked
See original GitHub issueIssue Type
[X] Bug
Description and/or steps/code to reproduce the problem
Update your app with osmdroid 6.0.0 to osmdroid 6.0.2 with a cache database > 400 MB. On first map launch it will crash if tiles are to be downloaded immediately and written with SqlTileWriter.saveFile, because the database is locked. I take this is caused by the database index creation update in #973 ? On second launch it’s working again.
04-19 10:39:39.749 E/SQLiteDatabase: Error inserting tile=[B@cb96fbd expires=1334919638000 provider=Mapnik key=905965568
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:783)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1548)
at android.database.sqlite.SQLiteDatabase.replace(SQLiteDatabase.java:1464)
at org.osmdroid.tileprovider.modules.SqlTileWriter.saveFile(SqlTileWriter.java:150)
at org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileDownloader.java:255)
at org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$TileLoader.run(MapTileModuleProviderBase.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
04-19 10:39:42.265 E/SQLiteDatabase: Error inserting tile=[B@5d34fd6 expires=1334880026000 provider=Mapnik key=905973758
android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(Native Method)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:783)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1548)
at android.database.sqlite.SQLiteDatabase.replace(SQLiteDatabase.java:1464)
at org.osmdroid.tileprovider.modules.SqlTileWriter.saveFile(SqlTileWriter.java:150)
at org.osmdroid.tileprovider.modules.MapTileDownloader$TileLoader.loadTile(MapTileDownloader.java:255)
at org.osmdroid.tileprovider.modules.MapTileModuleProviderBase$TileLoader.run(MapTileModuleProviderBase.java:315)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
04-19 10:39:42.578 E/AndroidRuntime: FATAL EXCEPTION: Thread-4
java.lang.NullPointerException: Attempt to invoke virtual method 'long java.io.File.length()' on a null object reference
at org.osmdroid.tileprovider.modules.SqlTileWriter.runCleanupOperation(SqlTileWriter.java:114)
at org.osmdroid.tileprovider.modules.SqlTileWriter$1.run(SqlTileWriter.java:69)
at org.osmdroid.util.GarbageCollector$1.run(GarbageCollector.java:31)
at java.lang.Thread.run(Thread.java:764)
If it’s a bug, version(s) of android this affects:
All
Version of osmdroid the issue relates to:
6.0.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:25 (10 by maintainers)
Top Results From Across the Web
Website Crashes at "Clear Caches" [#3247195] | Drupal.org
Problem/Motivation Upgrading a 8.9 site to the latest modules composer says: Lock file operations: 0 installs, 21 updates, ...
Read more >Fixed Issues (6.0.x) - Delphix Documentation
Fixed an issue of environment refresh failure for Windows host after upgrade to 6.0.16.0 occurred due to iSCSI related registry parameters' monitoring.
Read more >'Higher minimum deployment target' error when installing ...
Specs satisfying the `Firebase/Crash` dependency were found, but they required a higher minimum deployment target.` I've tried workarounds from ...
Read more >Redis 6.0 release notes - GitHub
Upgrade urgency HIGH: This release fixes a crash when builiding against Libc malloc. Here we revert 8110ba888, an optimization that causes a crash...
Read more >VMware vCenter Server 6.0 Update 2 Migration Release Notes
Migration Issues · Log in to the vCenter Server Windows OS as the Administrator. · Navigate to Start > Control Panel > Administrative...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Didn’t read the code yet, but the problem is, that index creation may take long. Question is, if you can provide an API call to trigger early index creation. I.e. my app has a splash screen, it would be easy to trigger index creation then and would run while various other things initialize and before the map activity is launched.
@monsieurtanuki Did some tests now:
On second test I deleted updated cache.db / cache.db-journal and recopied old ones, with the result of ongoing logs of
android.database.sqlite.SQLiteReadOnlyDatabaseException: attempt to write a readonly database
and no tiles shown. Closing the app doesn’t help, just reinstalling / rerunning from AS. I figured, that in the end we indeed need to close the DB. Tested the following inSqlTileWriter.onDetach
and it seems to do the trick. Any reason, why we shouldn’t close the DB even when detaching everything else? DB seems to stay locked internally forever…