On Wed, Nov 6, 2013 at 2:10 PM, Mayank Kumar (mayankum)
<[email protected]>wrote:

> Hi Sqlite Users
> I am running into a situation where sometimes after the power is restored
> my sqlite db running on linux is corrupted. Here is what I see with
> integrity_check:-
>
> *** in database main ***
> Page 895: btreeInitPage() returns error code 11
> On tree page 2 cell 765: Child page depth differs
> On tree page 2 cell 766: Child page depth differs
>

SQLite is suppose to recover automatically from a power loss, rolling back
the last transaction, and NOT corrupting the database file.

However, in order to do this, SQLite relies on the filesystem behaving as
advertised.  Corruption such as you describe can result from a broken
fsync() implementation or from consumer-grade disk drives that lie about
having flushed their track buffers (saying that they have flushed their
track buffers to oxide when in fact they have not).  Please read more at

    http://www.sqlite.org/howtocorrupt.html

Please note that setting "PRAGMA journal_mode=WAL" makes SQLite more
resistent to disk-drive lies.  Not immune, but more resistant.  You might
want to set WAL mode if you have not done so already.

-- 
D. Richard Hipp
[email protected]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to