Changes between Initial Version and Version 4 of Ticket #1566

09/21/2012 18:23:52 (12 years ago)

Re-titling to reflect the problem instead of a diagnosis that was likely premature/faulty.

After working on this codebase on the patchseries addressing #2317 and related dataloss/datacorruption issues with the datastore, my tendency is to NAK the proposed patch and the whole logic behind it.

The original report talks about "the Journal bringing up odd-looking entries", I take it to mean that we are working on corrupt/mismatched metadata between index and metadatastore.

A likely root cause for this is the implementation of propery storage in ; a patch addressing this is at , and commentary on the erroneous use of try/except/finally at . The metadatastore implementation is rather prone to data corruption / loss.

Once the writes to metadatastore are done defensively (atomically, in the patch linked), it is valid to ask whether it is worth calling fsync() to keep in rough sync with the index. The answer is no: all the filesystems used in Linux today have fsync() on a per-filesystem basis. All "dirty" buffers for the relevant filesystem are written out, not just the filehandle you passed.

So if the metadata changes are pending to be flushed when the index is flush()ed, the fsync() that Xapian invokes will _also_ flush metadata changes to disk.

I'll also note that currently we flush the Xapian db to disk every 5s, much lower than the 60s in use when originally reported.


  • Ticket #1566

    • Property Status changed from new to assigned
    • Property Cc erikos sascha_silbe added
    • Property Summary changed from Call fsync() for metadata writes to Fix metadata corruption
    • Property Owner changed from alsroot to martin.langhoff
    • Property Keywords r! added
  • Ticket #1566 – Description

    initial v4  
     1(Originally titled: Call fsync() for metadata writes)
    13While the ds index is force flushed every 60 seconds, the metadata files can often be in a non-flushed state for an undefined time interval. A force power off in such a situation makes the Journal bring up odd looking entries.