On Tue, Jun 8, 2010 at 6:32 AM, Nick Shaw <nick.s...@citysync.co.uk> wrote:

> 1) File/Disk corruption by the OS. On Windows, this can happen if the
> system suffers a power loss in the middle of a write, most noticeable
> when you're writing a large amount of data to a file (I realise it
> shouldn't happen, but I've seen it a number of times, especially on
> embedded XP devices);
>

After talking with my user a bit more, he reported that he had a power
outage around a week prior to the error.  Is it possible that some part of
the database became corrupt in a way that didn't immediately cause any
problems?  (e.g., a block that was in use became marked as a free or
somesuch?)

My application processes data in the background when the user isn't actively
using the computer, and this particular user throws quite a lot of data at
my application.  There's better-than-average odds that my application was
writing to the database when the power went out.


> 3) Something in your app is corrupting the stack or memory used by
> SqLite. That can cause no end of problems, and is usually very hard to
> pin down unless you can reproduce it.
>

Although I can't rule memory corruption out entirely, I think it's pretty
unlikely.  If my application had a general memory-corruption bug, I would
expect to occasionally get crash reports.  (My application automatically
creates a minidump and launches a Crash Reporter application in the event of
an invalid memory access)

If my application had a memory-corruption bug that was specifically misusing
a pointer used to interface with SQLite, that might not ever result in an
invalid memory access crash.  However, the bug would have to be in Python's
sqlite3 module.  Since that's pretty widely used, that also seems unlikely.


> If this is the first report you've ever had on this, and you have a fair
> few systems installed out in the field, my bet would be on #1.
>

It's the first report I've had.  I have a decent number of installations,
although this user probably puts my application under more stress than any
other user at the moment.

Definitely sounds like #1 is the most likely culprit.  Given that I
apparently cannot trust the OS/hardware to do the right thing during a power
outage, are there any best-practices for backing up the database?

I could do an integrity check on the database then copy the database file.
 That way, I only erase the old backup when I know the primary is good.
 However, my application will basically be unresponsive during this time.

I see that there's an online backup API, but a power outage during the
backup might leave me with two corrupt databases instead of just one (if I
understand correctly).

Thanks everyone for your input,
--
Daniel Stutzbach, Ph.D.
President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to