@@ -321,30 +321,35 @@ func (f *Freezer) Sync() error {
321321 return nil
322322}
323323
324- // validate checks that every table has the same length .
324+ // validate checks that every table has the same boundary .
325325// Used instead of `repair` in readonly mode.
326326func (f * Freezer ) validate () error {
327327 if len (f .tables ) == 0 {
328328 return nil
329329 }
330330 var (
331- length uint64
332- name string
331+ head uint64
332+ tail uint64
333+ name string
333334 )
334- // Hack to get length of any table
335+ // Hack to get boundary of any table
335336 for kind , table := range f .tables {
336- length = atomic .LoadUint64 (& table .items )
337+ head = atomic .LoadUint64 (& table .items )
338+ tail = atomic .LoadUint64 (& table .itemHidden )
337339 name = kind
338340 break
339341 }
340- // Now check every table against that length
342+ // Now check every table against those boundaries.
341343 for kind , table := range f .tables {
342- items := atomic .LoadUint64 (& table .items )
343- if length != items {
344- return fmt .Errorf ("freezer tables %s and %s have differing lengths: %d != %d" , kind , name , items , length )
344+ if head != atomic .LoadUint64 (& table .items ) {
345+ return fmt .Errorf ("freezer tables %s and %s have differing head: %d != %d" , kind , name , atomic .LoadUint64 (& table .items ), head )
346+ }
347+ if tail != atomic .LoadUint64 (& table .itemHidden ) {
348+ return fmt .Errorf ("freezer tables %s and %s have differing tail: %d != %d" , kind , name , atomic .LoadUint64 (& table .itemHidden ), tail )
345349 }
346350 }
347- atomic .StoreUint64 (& f .frozen , length )
351+ atomic .StoreUint64 (& f .frozen , head )
352+ atomic .StoreUint64 (& f .tail , tail )
348353 return nil
349354}
350355
0 commit comments