You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Christian Rodriguez <cr...@gmail.com> on 2004/10/19 23:55:11 UTC

Are index updates ATOMIC or not?

Hi,

First: I have read before a comment from Doug Cuttling saying that
"all index updates are atomic". Is this true? It looks like a bunch of
files are manipulated and in the end a rename of a file is done, which
"commits" the operation. If the operation is interrupted before it is
commited then it is just lost completely (and if any new files were
created they will be just silently overwritten). This makes the
operations atomic.

Am I correct about this?

Second: in FSDirectory.renameFile() there is a comment saying this
operation should be atomic. And that it is NOT currently atomic
because its implemented by a delete followed by a rename or copy
INSTEAD of just a simple rename (which is atomic in most file
systems). It looks as if 1. there is a "segments.new" that is created
and 2. it is renamed to "segments" (or deleted and copied).

Now, if there is a crash between the file being deleted and copied...
a comment says "we are screwed up". But what does screw up mean? Why
isnt the standard "crash recovery" just rename the segments.new file?
I mean, why not doing the following:

if there is a "segments", do nothing.
if there is no "segments" but there is a "segments.new" then rename it
to "segments".

Thanks!
Christian Rodriguez

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org