From 610346ae8c84fb4cc62bb947a516417637009548 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Tue, 20 Oct 2026 13:05:38 -0700 Subject: [PATCH] iceberg: keep version-hint.text out of remove_orphans (#11867) (#11871) Generated with [Devin](https://devin.ai) Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- weed/worker/tasks/iceberg/operations.go | 3 +++ weed/worker/tasks/iceberg/statistics_orphans_test.go | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/worker/tasks/iceberg/operations.go b/weed/worker/tasks/iceberg/operations.go index 1ec2f9c184..2266ad0ae3 100644 --- a/weed/worker/tasks/iceberg/operations.go +++ b/weed/worker/tasks/iceberg/operations.go @@ -342,6 +342,9 @@ func collectOrphanCandidates( } referencedFiles[path.Join("metadata", metadataFileName)] = struct{}{} + // Table-root readers (DuckDB iceberg_scan, Hadoop tables) open this to find + // the current metadata; nothing in the metadata references it. + referencedFiles[path.Join("metadata", "version-hint.text")] = struct{}{} for mle := range meta.PreviousFiles() { referencedFiles[mle.MetadataFile] = struct{}{} } diff --git a/weed/worker/tasks/iceberg/statistics_orphans_test.go b/weed/worker/tasks/iceberg/statistics_orphans_test.go index 6b56268c27..0b4ed5c4fe 100644 --- a/weed/worker/tasks/iceberg/statistics_orphans_test.go +++ b/weed/worker/tasks/iceberg/statistics_orphans_test.go @@ -57,6 +57,7 @@ func TestOrphanCleanupKeepsStatisticsFiles(t *testing.T) { filer.PutFile(metaDir, "stats-1.puffin", old) filer.PutFile(metaDir, "partition-stats-1.parquet", old) filer.PutFile(metaDir, "stats-0.puffin", old) // superseded: a real orphan + filer.PutFile(metaDir, "version-hint.text", old) candidates, err := collectOrphanCandidates(context.Background(), filer.Client, bucket, path.Join(namespace, tbl), meta, "v1.metadata.json", 1) @@ -70,7 +71,7 @@ func TestOrphanCleanupKeepsStatisticsFiles(t *testing.T) { if !doomed["stats-0.puffin"] { t.Fatalf("expected the unreferenced stats-0.puffin to be an orphan, got %v", doomed) } - for _, name := range []string{"stats-1.puffin", "partition-stats-1.parquet", "v1.metadata.json"} { + for _, name := range []string{"stats-1.puffin", "partition-stats-1.parquet", "v1.metadata.json", "version-hint.text"} { if doomed[name] { t.Errorf("%s is referenced by the table metadata and must not be an orphan", name) }