This makes sense now, thanks.

D. Richard Hipp, are there any plans to make this more robust in the future, so 
reading/writing a corrupt database (with no -journal file available) will 
return an *error* instead of causing further damage?

One idea: A "flag" could be added to the main database file to indicate that it 
has a corresponding -journal file. If it has the flag but no -journal file 
exists, that would be an error. To add the flag, Mac OS X has extended 
attributes. Not necessarily available on all filesystems, but a nice protection 
against corruption where available.

What do you think? Possible? Impossible?

----------------------------------------
> From: d...@sqlite.org
> Date: Sat, 30 Nov 2013 17:30:01 -0500
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Concrete example of corruption
>
> On Sat, Nov 30, 2013 at 5:15 PM, L. Wood <lwoo...@live.com> wrote:
>
>> Thanks, that makes sense.
>>
>> But I can pretty much rule this case out. In my case, it's highly unlikely
>> that the folder would be moved during the brief instant between _open() and
>> the actual opening of the "-journal" file.
>>
>> Are there other possible cases of corruption?
>>
>
>
>
> (1) Process A opens database at /first/path/to/database.db
> (2) The directory is renamed to /second/path/to/database.db
> (3) Process B begins writing to the database, creating a rollback journal
> at /second/path/to/database.db-journal
> (4) Process B crashes without committing or rolling back.
> (5) Process A tries to read the database. It checks for a hot journal
> file at /first/path/to/database.db-journal, finds none (since the hot
> journal is now in a different place) and therefore does not know that it
> needs to recover the database file. It sees the database as being corrupt.
> Or if A tries to write to the database, it makes the corruption worse, such
> that even a third process that does see the hot journal is no longer able
> to recover.
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users                  
>                   
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to