09-13-2013, 04:22 AM | #1 |
Junior Member
Posts: 7
Karma: 10
Join Date: Apr 2013
Device: PTS-T2
|
The SONY database is corrupted
Very nasty, when I connect a SONY PRS-t1, PRST2 or PRST3 I get in 50% of the cases the error:
Code:
calibre, version 1.3.0 ERREUR : Erreur: Erreur pendant la communication avec l'appareil connecté The SONY database is corrupted. Delete the file /Volumes/READER/Sony_Reader/database/books.db on your reader and then disconnect reconnect it. If you are using an SD card, you should delete the file on the card as well. Note that deleting this file will cause your reader to forget any notes/highlights, etc. Underlying error: Traceback (most recent call last): File "site-packages/calibre/devices/prst1/driver.py", line 293, in remove_orphaned_records DatabaseError: database disk image is malformed Traceback (most recent call last): File "site-packages/calibre/gui2/device.py", line 85, in run File "site-packages/calibre/gui2/device.py", line 476, in _books File "site-packages/calibre/devices/prst1/driver.py", line 163, in books File "site-packages/calibre/devices/usbms/driver.py", line 248, in books File "site-packages/calibre/devices/prst1/driver.py", line 246, in sync_booklists File "site-packages/calibre/devices/prst1/driver.py", line 276, in update_device_database File "site-packages/calibre/devices/prst1/driver.py", line 320, in remove_orphaned_records DeviceError: The SONY database is corrupted. Delete the file /Volumes/READER/Sony_Reader/database/books.db on your reader and then disconnect reconnect it. If you are using an SD card, you should delete the file on the card as well. Note that deleting this file will cause your reader to forget any notes/highlights, etc. Underlying error: Traceback (most recent call last): File "site-packages/calibre/devices/prst1/driver.py", line 293, in remove_orphaned_records DatabaseError: database disk image is malformed If I have a look on [URL="http://bazaar.launchpad.net/~kovid/calibre/trunk/view/head:/src/calibre/devices/prst1/driver.py"/devices/prst1/driver.py[/URL] I have the impression that the code should be able to continue to work even if remove_orphaned_records generates an exception. When I let rebuild the books.db, the SONY PRS generates empty collections/collection database entries. I have added the two databases for an investigation. |
09-13-2013, 05:16 AM | #2 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Try hard resetting your SONY or reformatting the memory, there's no way the code in the driver can cause a corrupted database on a properly functioning device.
|
Advert | |
|
09-20-2013, 03:44 AM | #3 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Apr 2013
Device: PTS-T2
|
Again the procedure to avoid the problem:
Actually I need to do this each time I want to use calibre. With the drawback that all notes and settings are lost. This is not reliable. Quote:
The only problem is that the database cleanup fails and here the question is why is this cleanup necessary? Can we skip it? If this is the case then it make sense not to generate an exception on a cleanup failure. I will do next week try to generate calibre from the sources and investigate more this issue. I will then put my remarks or patch in this forum. |
|
09-20-2013, 04:09 AM | #4 | ||
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
Quote:
Since 10s of thousands (a complete SWAG) of folks use calibre with PRS-T2 devices without error I'll be interested in to see what you find. Last edited by DoctorOhh; 09-20-2013 at 05:34 AM. Reason: added without error |
||
09-20-2013, 04:45 AM | #5 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Apr 2013
Device: PTS-T2
|
Quote:
So it is possible that books.db get partially cleanup when a failure occurs. This is not really good: it would be better to do backup of books.db before the cleanup and revert to the backup once the operation fails. I'm also not sure if the failure is not a temporary failure: books.db is generated in background by the device. So it is possible that I access to it while it is not completely generated. But it is wrong to alter it if we cannot process it. (and so made it corrupt for the device) |
|
Advert | |
|
09-20-2013, 05:12 AM | #6 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
09-20-2013, 05:13 AM | #7 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
An exception that prevents further cleanup cannot cause a malformed database, I suggest you read up on how sqlite works if you dont understand why.
|
09-20-2013, 05:30 AM | #8 | |
US Navy, Retired
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
|
Quote:
I have since updated the original post. Last edited by DoctorOhh; 09-20-2013 at 07:30 AM. |
|
09-20-2013, 07:29 AM | #9 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Apr 2013
Device: PTS-T2
|
Quote:
So the cleanup is partially executed on books.db. But your reaction is for me suspicious: you simply say that your code work without investigating it. Googgle a little bit and you will see that I'm not alone with this issue, but since I'm able to reproduce it and I plan to investigate some time on it you should be happy to give me some advices on your code. This is obviously not the case! Code:
def remove_orphaned_records(self, connection, dbpath): from sqlite3 import DatabaseError try: cursor = connection.cursor() debug_print("Removing Orphaned Collection Records") # Purge any collections references that point into the abyss query = 'DELETE FROM collections WHERE content_id NOT IN (SELECT _id FROM books)' cursor.execute(query) <---- this was executed query = 'DELETE FROM collections WHERE collection_id NOT IN (SELECT _id FROM collection)' cursor.execute(query) <---- location of the exception ........... except DatabaseError: ....... |
|
09-20-2013, 07:57 AM | #10 |
creator of calibre
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Sigh.
Let me spell it out for you: The error you are getting is database disk image is malformed That error means that sqlite thinks the database is corrupted That cannot happen if a query fails because of a property of sqlite known as ACID, which means that no matter what failure occurs during a query, the database on disk cannot be corrupted, unless a filesystem operation fails. Therefore, the only way that you can get that error is through one of the two following scenarios: 1) A bug in sqlite 2) A bug in the filesystem layer that accesses the db on your device Neither of those are bugs in the t1 driver. And just by the by, I did not write the t1 driver, nor do I maintain it. I am just trying to help you avoid wasting time looking for problems in the wrong place. But I'm done helping you, all the best in your endeavors. |
09-22-2013, 04:39 AM | #11 | |
Junior Member
Posts: 7
Karma: 10
Join Date: Apr 2013
Device: PTS-T2
|
Quote:
Anyway, next week I will have a try to debug it since I have the problem with all my devices and quite often. IT is certainly the best chance to find what is going wrong. If I'm able to find something, you will see a get-merge request with a patch. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Corrupted database | Qylie | Calibre | 8 | 08-28-2014 02:02 AM |
Help! Corrupted database problem | Marok | Library Management | 12 | 06-24-2013 09:01 AM |
[Old Thread] Corrupted library database | smarties86 | Calibre | 2 | 09-02-2012 06:30 AM |
Corrupted database | garyft | Calibre | 3 | 05-13-2011 02:10 PM |
Grrr... Corrupted Database | PeterT | Kobo Reader | 4 | 01-09-2011 10:36 PM |