@@ -318,30 +318,35 @@ func (f *Freezer) Sync() error {
318318 return nil
319319}
320320
321- // validate checks that every table has the same length .
321+ // validate checks that every table has the same boundary .
322322// Used instead of `repair` in readonly mode.
323323func (f * Freezer ) validate () error {
324324 if len (f .tables ) == 0 {
325325 return nil
326326 }
327327 var (
328- length uint64
329- name string
328+ head uint64
329+ tail uint64
330+ name string
330331 )
331- // Hack to get length of any table
332+ // Hack to get boundary of any table
332333 for kind , table := range f .tables {
333- length = atomic .LoadUint64 (& table .items )
334+ head = atomic .LoadUint64 (& table .items )
335+ tail = atomic .LoadUint64 (& table .itemHidden )
334336 name = kind
335337 break
336338 }
337- // Now check every table against that length
339+ // Now check every table against those boundaries.
338340 for kind , table := range f .tables {
339- items := atomic .LoadUint64 (& table .items )
340- if length != items {
341- return fmt .Errorf ("freezer tables %s and %s have differing lengths: %d != %d" , kind , name , items , length )
341+ if head != atomic .LoadUint64 (& table .items ) {
342+ return fmt .Errorf ("freezer tables %s and %s have differing head: %d != %d" , kind , name , atomic .LoadUint64 (& table .items ), head )
343+ }
344+ if tail != atomic .LoadUint64 (& table .itemHidden ) {
345+ return fmt .Errorf ("freezer tables %s and %s have differing tail: %d != %d" , kind , name , atomic .LoadUint64 (& table .itemHidden ), tail )
342346 }
343347 }
344- atomic .StoreUint64 (& f .frozen , length )
348+ atomic .StoreUint64 (& f .frozen , head )
349+ atomic .StoreUint64 (& f .tail , tail )
345350 return nil
346351}
347352
0 commit comments