Will Leshner <[EMAIL PROTECTED]> wrote:
> On Jan 20, 2006, at 7:41 AM, [EMAIL PROTECTED] wrote:
> 
> > The database might be completely unusable.  It depends on
> > which writes completed and which had not at the time of the
> > crash.
> 
> Am I right in thinking that that would be more likely to happen in,  
> say, a hardware failure, and less likely to happen if the crash  
> occurs because of a bug in my code? In other words, if every SQLite  
> call returns successfully, is it unlikely that the database is in an  
> unusable state?
> 

Deleting a hot journal after a power loss or OS crash is more 
likely to result in severe database corruption, but database 
corruption is possible from deleting a hot journal after an
ordinary program crash. 

Here is one scenario for generating reasonably severe database
corruption by crashing a program:

   (1)  Start a transaction
   (2)  Make *many* changes to the database - so many that
        the internal cache overflows and has to spill to disk.
   (3)  Crash the program.
   (4)  Delete the journal file

Another way to get database corruption from a program crash
is to crash the program during a COMMIT and then delete the
journal.  This might happen, for example, if one thread is 
doing a COMMIT and a different thread happens to segfault at
the same time.  (Yet another reason to not used threads!)

--
D. Richard Hipp <[EMAIL PROTECTED]>


Reply via email to