@@ -307,11 +307,12 @@ func readFooter(
307307 f objstorage.Readable ,
308308 readHandle objstorage.ReadHandle ,
309309 logger base.LoggerAndTracer ,
310+ fileNum base.DiskFileNum ,
310311) (footer , error ) {
311312 var footer footer
312313 size := f .Size ()
313314 if size < minFooterLen {
314- return footer , base .CorruptionErrorf ("pebble/table: invalid table (file size is too small)" )
315+ return footer , base .CorruptionErrorf ("pebble/table: invalid table %s (file size is too small)" , errors . Safe ( fileNum ) )
315316 }
316317
317318 buf := make ([]byte , maxFooterLen )
@@ -342,7 +343,7 @@ func readFooter(
342343 case levelDBMagic :
343344 if len (buf ) < levelDBFooterLen {
344345 return footer , base .CorruptionErrorf (
345- "pebble/table: invalid table (footer too short): %d" , errors .Safe (len (buf )))
346+ "pebble/table: invalid table %s (footer too short): %d" , errors . Safe ( fileNum ) , errors .Safe (len (buf )))
346347 }
347348 footer .footerBH .Offset = uint64 (off + int64 (len (buf ))) - levelDBFooterLen
348349 buf = buf [len (buf )- levelDBFooterLen :]
@@ -354,14 +355,14 @@ func readFooter(
354355 // NOTE: The Pebble magic string implies the same footer format as that used
355356 // by the RocksDBv2 table format.
356357 if len (buf ) < rocksDBFooterLen {
357- return footer , base .CorruptionErrorf ("pebble/table: invalid table (footer too short): %d" , errors .Safe (len (buf )))
358+ return footer , base .CorruptionErrorf ("pebble/table: invalid table %s (footer too short): %d" , errors . Safe ( fileNum ) , errors .Safe (len (buf )))
358359 }
359360 footer .footerBH .Offset = uint64 (off + int64 (len (buf ))) - rocksDBFooterLen
360361 buf = buf [len (buf )- rocksDBFooterLen :]
361362 footer .footerBH .Length = uint64 (len (buf ))
362363 version := binary .LittleEndian .Uint32 (buf [rocksDBVersionOffset :rocksDBMagicOffset ])
363364
364- format , err := ParseTableFormat (magic , version )
365+ format , err := ParseTableFormat (magic , version , fileNum )
365366 if err != nil {
366367 return footer , err
367368 }
@@ -373,26 +374,26 @@ func readFooter(
373374 case block .ChecksumTypeXXHash64 :
374375 footer .checksum = block .ChecksumTypeXXHash64
375376 default :
376- return footer , base .CorruptionErrorf ("pebble/table: unsupported checksum type %d" , errors .Safe (footer .checksum ))
377+ return footer , base .CorruptionErrorf ("pebble/table: invalid table %s ( unsupported checksum type %d)" , errors . Safe ( fileNum ) , errors .Safe (footer .checksum ))
377378 }
378379 buf = buf [1 :]
379380
380381 default :
381- return footer , base .CorruptionErrorf ("pebble/table: invalid table (bad magic number: 0x%x)" , magic )
382+ return footer , base .CorruptionErrorf ("pebble/table: invalid table %s (bad magic number: 0x%x)" , errors . Safe ( fileNum ) , magic )
382383 }
383384
384385 {
385386 end := uint64 (size )
386387 var n int
387388 footer .metaindexBH , n = decodeBlockHandle (buf )
388389 if n == 0 || footer .metaindexBH .Offset + footer .metaindexBH .Length > end {
389- return footer , base .CorruptionErrorf ("pebble/table: invalid table (bad metaindex block handle)" )
390+ return footer , base .CorruptionErrorf ("pebble/table: invalid table %s (bad metaindex block handle)" , errors . Safe ( fileNum ) )
390391 }
391392 buf = buf [n :]
392393
393394 footer .indexBH , n = decodeBlockHandle (buf )
394395 if n == 0 || footer .indexBH .Offset + footer .indexBH .Length > end {
395- return footer , base .CorruptionErrorf ("pebble/table: invalid table (bad index block handle)" )
396+ return footer , base .CorruptionErrorf ("pebble/table: invalid table %s (bad index block handle)" , errors . Safe ( fileNum ) )
396397 }
397398 }
398399
0 commit comments