This object is in archive! 

Offline map tile database corrupted

tkansgar shared this problem 2 years ago
Solved

Hi,

since some days my most important offline map tile database becomes corrupted, when I try to calculate the number of updatable map tiles of a particular zoom level. The sqlitedb file then has a very small size (some kB, normally its size is ~4 GB). Fortunately beside it there is a backup version of the original one. So I simply can close Locus Map, delete the corrupted one, rename the backup file to the original name and start Locus Map again. So I thought, there must be a hidden error in the database, copied the sqlitedb file to my PC and localisied it with SQLite Administrator. The image of one single entry in the tiles table is corrupted. Sadly, SQLite Administrator is not very verbose, when reporting the error:


20.08.2022 13:50:30: SQL Error: SQL logic error or missing database < select image from tiles<br>where z = 2
and x = 17176
and y = 10814;>
The other values x, y, z and s of this entry can be selected properly. And the image of any other entry can be selected too (is reported as "‰PNG" by SQLite Administrator). So my question is, can I fix or delete this corrupted entry in any way? Trying to delete it using the same where clause ends up with the same error:

20.08.2022 13:51:21: SQL Error: SQL logic error or missing database < delete from tiles
where z = 2
and x = 17176
and y = 10814;>
What can I do to repair my map tile database?

BR

tkansgar

Best Answer
photo

Full success! Instead of

sqlite3.exe filename.db ".dump" | sqlite3 new.db
like you wrote in your document linked above, which didn't help in my case, I symply did

sqlite3.exe filename.db ".recover" | sqlite3 new.db

Then I renamed new.db to the original name, copied it back into the maps folder on my smartphone, started Locus Map again, and voila, calculating the number of updatable map tiles and downloading them works again properly.

One additional note: After I had copied the last version of my database from my smartphone to my PC and directly executed my modified command, the lost_and_found table didn't exist. It obviously only existed, after I had modified the original database with SQLite Administrator and then did the recover command to this modified database. But maybe there is no warranty, that lost_and_found won't be added to the new.db. So you should keep in mind, that it could exist, and tink of, what to do with it.


Perhaps you could recommend to try it with ".recover" in your document, if ".dump" does not help.

BR

tkansgar

Replies (3)

photo
1

Hello tkansgar,

sorry to read this, but it simply rarely happens. Because of similar problems, I wrote this document a long time ago, so you may give it a try. Seems you are quite skilled, so it should be no problem for you to try it. Hope this helps.

Menion

photo
1

Hi Menion,

I just executed those commands, but the result database is of size 0 bytes. Of course, the integrity_check now says "ok" for this one. I don't think, this is a proper solution for my issue. But I will see, what else sqlite3 can do for my database. Will come back again.

BR

tkansgar

photo
1

Hello,

hmm damn. I always use these steps to fix databases with points/tracks send to us from users. In case, this fail, there is usually no other option I know. Good luck!

photo
1

I replaced ".dump" by ".recover". This created a new proper database obviously containing many correct tiles entries. Additionally there is a new table named lost_and_found containing data, which were detected as corrupt. Many of them seem to contain a proper PNG. Currently I'm analysing, how I could restore those data back to the tiles table. Don't know, whether this is possible.

[EDIT] But very interesting: The corrupted entry reported above obviously is repaired already, meaning it has a PNG and doesn't lead to an error anymore. Maybe I simply can remove the lost_and_found table.

photo
1

Full success! Instead of

sqlite3.exe filename.db ".dump" | sqlite3 new.db
like you wrote in your document linked above, which didn't help in my case, I symply did

sqlite3.exe filename.db ".recover" | sqlite3 new.db

Then I renamed new.db to the original name, copied it back into the maps folder on my smartphone, started Locus Map again, and voila, calculating the number of updatable map tiles and downloading them works again properly.

One additional note: After I had copied the last version of my database from my smartphone to my PC and directly executed my modified command, the lost_and_found table didn't exist. It obviously only existed, after I had modified the original database with SQLite Administrator and then did the recover command to this modified database. But maybe there is no warranty, that lost_and_found won't be added to the new.db. So you should keep in mind, that it could exist, and tink of, what to do with it.


Perhaps you could recommend to try it with ".recover" in your document, if ".dump" does not help.

BR

tkansgar

photo
1

Hmm perfect, thanks for info!

Manual updated.

Jiří M. aka Menion

Replies have been locked on this page!