View Single Post
Old 10-13-2012, 04:48 PM   #1
sja45uk
Junior Member
sja45uk began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Oct 2012
Device: Sony PRS-500
Exclamation Serious problem with Calibre metadata.db

I have a serious problem with Calibre 0.9.2 on my Win7 laptop.

I have attempted to reconstruct from notes the following as my attempted recovery sequence but cannot guarantee the order of commands in detail.

I was actively using Calibre when the laptop crashed. I suspect something caused a hard disk problem which caused Windows to reboot. I do not know if it was caused by Windows, Calibre or the laptop hardware as the laptop boot complained it could not find the Operating System but Windows correctly started after a power-off and power-on.

I then used the standard Windows Check Disk on reboot to both: Automatically fix file system errors, and; Scan for and attempt recovery of bad sectors.

Then I tried to run Calibre but I got a calibre.exe is not responding error.

I then tried calibre-debug.exe -g

calibre 0.9.2
Windows-7-6.1.7601-SP1
<'Windows', '7', '6.1.7601'>
Python 2.7.3
Windows: <'7', '6.1.7601', 'SP1', 'Multiprocessor Free'>
Starting up...

Catostrophic failure initializing GUI, bailing out...

I also got a popup window containing the following information:

calibre, version 0.9.2
ERROR: Failed: Restoring database failed, click Show details to see details

Traceback (most recent call last):
File "site-packages\calibre\library\restore.py", line 116, in run
File "site-packages\calibre\library\restore.py", line 279, in replace_db
WindowsError: [Error 32] The process cannot access the file because it is being used by another process

I thought that the calibre installation might be corrupt so I used the file calibre-0.9.2.msi to perform a repair.

At some point calibre asked me the following:

Choose a location for your new calibre e-book library

In doubt of the correct answer, I cancelled out and it has never been asked again so I am not sure which piece of software was asking it as I have performed the calibre installation repair more than once.

Then I tried the following command:
calibredb restore_database --really-do-it

Restoring database succeeded
old database saved as C:\Users\Steve\Calibre Library\metadata_pre_restore.db
Some errors occurred.
A detailed report was saved to calibre_db_restore_report.txt

This showed three different categories of minor problem:

One instance of:
File "site-packages\calibre\library\restore.py", line 159, in scan_library
File "site-packages\calibre\library\restore.py", line 181, in process_dir
File "site-packages\calibre\ebooks\metadata\opf2.py", line 564, in __init__
File "xpath.pxi", line 455, in lxml.etree.XPath.__call__ (src/lxml/lxml.etree.c:115107)
File "apihelpers.pxi", line 37, in lxml.etree._documentOrRaise

(src/lxml/lxml.etree.c:11215)
TypeError: Invalid input object: NoneType

Two instances of:
File "site-packages\calibre\library\restore.py", line 245, in restore_books
File "site-packages\calibre\library\restore.py", line 268, in restore_book
File "site-packages\calibre\library\sqlite.py", line 313, in run
IntegrityError: columns book, format are not unique

Eleven instances of:
File "site-packages\calibre\library\restore.py", line 245, in restore_books
File "site-packages\calibre\library\restore.py", line 259, in restore_book
File "site-packages\calibre\library\database2.py", line 3352, in create_book_entry
File "site-packages\calibre\library\sqlite.py", line 313, in run
IntegrityError: PRIMARY KEY must be unique

Not bad for a database that before the crash contained more than ten thousand books and nothing to indicate any other problems. However, calibre still will not start so I tried another database repair command:

C:\Users\Steve\Calibre Library> calibre-debug --reinitialise-db metadata.db

Python function terminated unexpectedly
disk I/O error
RemoteTraceback (most recent call last):
File "site-packages\calibre\library\sqlite.py", line 248, in run
File "site-packages\calibre\library\sqlite.py", line 226, in connect
OperationalError: disk I/O error (Error Code: 1)
Traceback (most recent call last):
File "site.py", line 132, in main
File "site.py", line 109, in run_entry_point
File "site-packages\calibre\library\debug.py", line 260, in main
File "site-packages\calibre\library\debug.py", line 260, in main
File "site-packages\calibre\library\sqlite.py", line 366, in connect
calibre.library.sqlite.DatabaseException: disk I/O error
RemoteTraceback (most recent call last):
File "site-packages\calibre\library\sqlite.py", line 248, in run
File "site-packages\calibre\library\sqlite.py", line 226, in connect
OperationalError: disk I/O error (Error Code: 1)

The metadata.db and metadata_pre_restore.db are both the same size (20,660 KB), but if I examine them with SQLite Database Browser 2.0 b1.exe metadata_pre_restore.db shows content (although it only contains about 4000 books) but metadata.db appears to be empty.

When I try to run calibre it still hangs and error.txt contains the following:
Python function terminated unexpectedly
disk I/O error
RemoteTraceback (most recent call last):
File "site-packages\calibre\library\sqlite.py", line 248, in run
File "site-packages\calibre\library\sqlite.py", line 226, in connect
OperationalError: disk I/O error (Error Code: 1)

However, I can copy metadata.db using Windows Explorer so I do not understand the error or what I can do next.

Is it an sqlite error and what does it mean?

The permissions appear to be identical for both metadata .db files, so I cannot think of any more fixes to try without more knowledge of the errors and expected recovery behaviour. Thanks, and I apologize for the length of this account of a so-far unsuccessful recovery.
sja45uk is offline   Reply With Quote