@@ -446,8 +446,8 @@ func (t *freezerTable) repairIndex() error {
446446 continue
447447 }
448448 // Ensure that the first non-head index refers to the earliest file,
449- // or the next file if the earliest file is not sufficient to
450- // place the first item.
449+ // or the next file if the earliest file has no space to place the
450+ // first item.
451451 if offset == indexEntrySize {
452452 if entry .filenum != head .filenum && entry .filenum != head .filenum + 1 {
453453 log .Error ("Corrupted index item detected" , "earliest" , head .filenum , "filenumber" , entry .filenum )
@@ -474,11 +474,18 @@ func (t *freezerTable) repairIndex() error {
474474 return nil
475475}
476476
477- // checkIndexItems checks the validity of two consecutive index items. The index
478- // item is regarded as invalid if:
479- // - file number of two index items are not same and not monotonically increasing
480- // - data offset of two index items with same file number are out of order
481- // - zero data offset with an increasing file number
477+ // checkIndexItems validates the correctness of two consecutive index items based
478+ // on the following rules:
479+ //
480+ // - The file number of two consecutive index items must either be the same or
481+ // increase monotonically. If the file number decreases or skips in a
482+ // non-sequential manner, the index item is considered invalid.
483+ //
484+ // - For index items with the same file number, the data offset must be in
485+ // non-decreasing order. Note: Two index items with the same file number
486+ // and the same data offset are permitted if the entry size is zero.
487+ //
488+ // - The first index item in a new data file must not have a zero data offset.
482489func (t * freezerTable ) checkIndexItems (a , b indexEntry ) error {
483490 if b .filenum != a .filenum && b .filenum != a .filenum + 1 {
484491 return fmt .Errorf ("index items with inconsistent file number, prev: %d, next: %d" , a .filenum , b .filenum )
0 commit comments