question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error due to closed db connection

See original GitHub issue

Issue Type

[x] Bug

Description and/or steps/code to reproduce the problem

Seeing this intermittently on at least API 15 emulators while running connected tests. Relevant logcat excerpt: W/OsmDroid( 1580): Error getting db stream: /2/1/0 W/OsmDroid( 1580): java.lang.IllegalStateException: database /mnt/sdcard/osmdroid/testzoom4.sqlite (conn# 0) already closed W/OsmDroid( 1580): at android.database.sqlite.SQLiteDatabase.verifyDbIsOpen(SQLiteDatabase.java:2082) W/OsmDroid( 1580): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:413) W/OsmDroid( 1580): at android.database.sqlite.SQLiteDatabase.lock(SQLiteDatabase.java:400) W/OsmDroid( 1580): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:79) W/OsmDroid( 1580): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164) W/OsmDroid( 1580): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.DatabaseFileArchive.getImage(DatabaseFileArchive.java:91) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.DatabaseFileArchive.getInputStream(DatabaseFileArchive.java:110) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider.getInputStream(MapTileFileArchiveProvider.java:195) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider.access$100(MapTileFileArchiveProvider.java:29) W/OsmDroid( 1580): at org.osmdroid.tileprovider.modules.MapTileFileArchiveProvider$TileLoader.loadTile(MapTileFileArchiveProvider.java:229) W/OsmDroid( 1580): at org.osmdroid.tileprovider.MapTilePreCache.search(MapTilePreCache.java:99) W/OsmDroid( 1580): at org.osmdroid.tileprovider.MapTilePreCache.access$100(MapTilePreCache.java:26) W/OsmDroid( 1580): at org.osmdroid.tileprovider.MapTilePreCache$1.run(MapTilePreCache.java:37) W/OsmDroid( 1580): at org.osmdroid.util.GarbageCollector$1.run(GarbageCollector.java:31) W/OsmDroid( 1580): at java.lang.Thread.run(Thread.java:856) D/OsmDroid( 1580): TileLoader failed to load tile due to mWriter being null (map shutdown?)

Full logcat: https://api.travis-ci.org/v3/job/396125119/log.txt

Don’t know if this related to the tests itself or might be a concurrency issue related to the new GC functionality. Maybe @monsieurtanuki can take a look?

Environment

If it’s a bug, version(s) of android this affects:

at least API 15

Version of osmdroid the issue relates to:

6.0.2

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
monsieurtanukicommented, Jun 24, 2018

@cbalster If I remember well, with the new GC feature we never explicitly close the db.

I see in the logs something like “TileLoader failed to load tile due to mWriter being null”.

My first guest: when the test is over we “detach” the fragment and set the mWriter to null, which somehow implicitly closes the db, while in the same time the GC is running.

A simple fix would be to say in the GC: “btw if the db is closed don’t try to do anything” (as it’s pointless - and prone to bug - in that case anyway)

0reactions
spyhunter99commented, Jul 16, 2018

ok well we’ll close for now and reopen if needed

Read more comments on GitHub >

github_iconTop Results From Across the Web

java.sql.SQLException: database connection closed
This try-with-resources construct will invoke method close on Connection when you leave its scope: try (Connection conn = DriverManager.
Read more >
Handling java.sql.SQLRecoverableException: Closed ...
This error message indicates that the connection used by the backup task (or any other long-running operation that relies on a single database ......
Read more >
How to deal with closed connections in database pool
Such closed connections (commonly known as "infected" connections) may be caused by the database, which closes a connection due to a "idle connection...
Read more >
Closed connections from database cause error
If the database is restarted, or if a connection expires, a query that uses the connection will receive an error.
Read more >
How to Fix Error Establishing a Database Connection Error
The error establishing a database connection error basically means that for some reason or another the PHP code was unable to connect to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found