Files
seaweedfs/weed/worker/tasks/iceberg/read_guard_test.go
T
Javier de la Torreanduser.email edf2b0f5ee iceberg maintenance: an unreadable parquet file fails the job, not the process (#12188)
* iceberg maintenance: an unreadable parquet file fails the job, not the process

parquet.NewReader panics on any file it cannot open (wrong magic, a
truncated footer, zero bytes), and parquet-go's row decoder panics on a
corrupt page under a valid footer. Maintenance runs in the worker's
goroutines with no recover, so one bad delete or data file in any table
ended the whole process.

- Every parquet open in compaction goes through newParquetReader, which
  opens with parquet.OpenFile and returns the error.
- A panic while decoding a delete file or a data file's rows is recovered
  into an error naming the file (recoverRead/guardRead).
- As a backstop, detection recovers per table and Execute per operation:
  the table is skipped or the operation fails, and the worker keeps
  running.

A failed delete file still fails the table's compaction (no commit), as a
read error did before; a failed data file still skips only its bin.

* iceberg maintenance: test a corrupt page inside a merge fails it naming the file

* iceberg maintenance: assert a skipped bin's files stay in the snapshot

---------

Co-authored-by: user.email <chrislusf@users.noreply.github.com>
2026-10-29 00:10:47 -07:00

23 lines
657 B
Go

package iceberg
import (
"errors"
"strings"
"testing"
)
func TestGuardReadTurnsAPanicIntoAnError(t *testing.T) {
v, err := guardRead("data/x.parquet", func() (int, error) {
var s []int
return s[3], nil // index out of range
})
if v != 0 || err == nil || !strings.Contains(err.Error(), "data/x.parquet") || !strings.Contains(err.Error(), "panic") {
t.Fatalf("v = %d, err = %v: want a zero value and an error naming the file", v, err)
}
want := errors.New("plain error")
if _, err := guardRead("data/y.parquet", func() (int, error) { return 0, want }); err != want {
t.Fatalf("err = %v, want the function's own error unchanged", err)
}
}