Hi everybody,
We have encountered two corrupted databases so far at customers and
we have no idea how they could become corrupted (we haven't had any
corruption in house so far).
(Yes, I've read the "How to corrupt your database files" section, but
I don't think any of the methods mentioned there would apply...)
Our app is heavily threaded, but we do pay strict attention to never
pass database connection handles between threads. Essentially each
thread opens it's own connection.
The first corruption could apparently be fixed by running vaccuum
(pragma integrity_check was reporting just a missing element in an
index).
The second corruption was much more severe and integrity_check
reported lots of issues:
*** in database main ***
Page 15857: initPage() returns error code 11
On tree page 89 cell 27: Child page depth differs
On tree page 89 cell 28: Child page depth differs
On tree page 15822 cell 8: 2nd reference to page 15866
On tree page 15822 cell 8: Child page depth differs
Page 15858: initPage() returns error code 11
On tree page 14454 cell 106: Child page depth differs
On tree page 14454 cell 107: Child page depth differs
On tree page 4 cell 48: 2nd reference to page 15862
On tree page 4 cell 48: Child page depth differs
On tree page 4 cell 49: Child page depth differs
On tree page 4 cell 51: 2nd reference to page 15872
On tree page 4 cell 51: Child page depth differs
On tree page 4 cell 52: 2nd reference to page 15873
On tree page 4 cell 53: 2nd reference to page 15874
On tree page 4 cell 54: Child page depth differs
On tree page 4 cell 56: 2nd reference to page 15871
On tree page 4 cell 56: Child page depth differs
On page 4 at right child: 2nd reference to page 15870
On page 15243 at right child: 2nd reference to page 15869
On tree page 4571 cell 90: 2nd reference to page 15860
On tree page 4571 cell 90: Child page depth differs
On page 4571 at right child: 2nd reference to page 15865
On tree page 3493 cell 92: 2nd reference to page 15864
On tree page 3493 cell 92: Child page depth differs
On page 3493 at right child: 2nd reference to page 15867
On tree page 14464 cell 67: 2nd reference to page 15863
On tree page 14464 cell 67: Child page depth differs
On tree page 14464 cell 68: 2nd reference to page 15868
On tree page 14464 cell 69: Child page depth differs
On tree page 5091 cell 120: 2nd reference to page 15861
On tree page 5091 cell 120: Child page depth differs
On tree page 5091 cell 121: Child page depth differs
plus a whole lot of
"rowid xxx missing from index yyy"
and
"wrong # of entries in index yyy"
lines
Vacuuming failed with error 19
What's the best approach to try and rescue such a corrupt database?
So far, I've sort of succeeded by using '.dump' to dump each single
table (the global '.dump' would only dump 3 out of about 20 tables).
Unfortunately, some of the data appears to be out of place (i.e. data
from other tables), but most of the data looks pretty much o.k., but
it's not easy to verify :(
I'm a bit weary that we might get more reports about corrupted
databases from customers, so I really want to find out what would
cause the corruption!
If there's anything I can do to help analyze the corruption to find
out why and where it occurs, please let me know.
Thanks,
</jum>
P.S.: the sqlite version used at the customer site was 3.3.4