[KinoSearch] Fencepost error in IndexManager->recycle

Marvin Humphrey marvin at rectangular.com
Tue Aug 18 17:17:01 PDT 2009


Greets,

A fencepost error has been found in IxManager_Recycle() which is likely to
affect indexes with deletions.

Here's the fix:

     /* Find segments where at least 10% of all docs have been deleted. */
-    for (i = threshold; i < num_seg_readers; i++) {
+    for (i = threshold + 1; i < num_seg_readers; i++) {

If the segment located at "threshold" in the array of candidates also had a
deletion rate of 10% or more, this bug would cause it to be added *twice* to
the list of segments to merge.  Merging the segment twice causes its documents
to be duplicated.  It also can have a bizarre side effect of causing unexpected
disappearance of deletions, due to incorrect results for this test in
Indexer.c:

       /* Only write out if they haven't all been applied. */
        if (VA_Get_Size(to_merge) != num_seg_readers) {
            DelWriter_Finish(self->del_writer);
        }

The bug is fixed by commit r5117; a release will follow after I run the usual
preparations.

Marvin Humphrey




More information about the kinosearch mailing list