You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iceberg.apache.org by ze...@apache.org on 2026/04/03 20:00:26 UTC

(iceberg-go) branch main updated: Thread context.Context through deletedEntries() (#847)

This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg-go.git


The following commit(s) were added to refs/heads/main by this push:
     new 311cc3c7 Thread context.Context through deletedEntries() (#847)
311cc3c7 is described below

commit 311cc3c7f333c860ff30e32970948fbbff739a59
Author: TT <70...@users.noreply.github.com>
AuthorDate: Fri Apr 3 22:00:20 2026 +0200

    Thread context.Context through deletedEntries() (#847)
    
    ## Summary
    - Thread `context.Context` through the `deletedEntries()` call chain,
    replacing `context.TODO()` with a real context propagated from the write
    transaction
    - This allows cancellation to propagate to manifest reads during
    overwrite commits
    
    ## Changes
    - `producerImpl.deletedEntries()` → `deletedEntries(ctx
    context.Context)`
    - `snapshotProducer.manifests()` → `manifests(ctx context.Context)`
    - `snapshotProducer.commit()` → `commit(ctx context.Context)`
    - Updated all call sites in `transaction.go`, `row_delta.go`, and tests
    to pass `ctx`
    
    Closes #838
---
 table/row_delta.go               |  2 +-
 table/snapshot_producers.go      | 16 ++++++++--------
 table/snapshot_producers_test.go | 22 +++++++++++-----------
 table/transaction.go             | 14 +++++++-------
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/table/row_delta.go b/table/row_delta.go
index df0072c9..83f06199 100644
--- a/table/row_delta.go
+++ b/table/row_delta.go
@@ -153,7 +153,7 @@ func (rd *RowDelta) Commit(ctx context.Context) error {
 		producer.appendDeleteFile(f)
 	}
 
-	updates, reqs, err := producer.commit()
+	updates, reqs, err := producer.commit(ctx)
 	if err != nil {
 		return err
 	}
diff --git a/table/snapshot_producers.go b/table/snapshot_producers.go
index 8de01dfa..7f5ba973 100644
--- a/table/snapshot_producers.go
+++ b/table/snapshot_producers.go
@@ -46,7 +46,7 @@ type producerImpl interface {
 	// manifests that should be included in the snapshot
 	existingManifests() ([]iceberg.ManifestFile, error)
 	// return the deleted entries for writing delete file manifests
-	deletedEntries() ([]iceberg.ManifestEntry, error)
+	deletedEntries(ctx context.Context) ([]iceberg.ManifestEntry, error)
 }
 
 func newManifestFileName(num int, commit uuid.UUID) string {
@@ -97,7 +97,7 @@ func (fa *fastAppendFiles) existingManifests() ([]iceberg.ManifestFile, error) {
 	return existing, nil
 }
 
-func (fa *fastAppendFiles) deletedEntries() ([]iceberg.ManifestEntry, error) {
+func (fa *fastAppendFiles) deletedEntries(_ context.Context) ([]iceberg.ManifestEntry, error) {
 	// for fast appends, there are no deleted entries
 	return nil, nil
 }
@@ -197,7 +197,7 @@ func (of *overwriteFiles) existingManifests() ([]iceberg.ManifestFile, error) {
 	return existingFiles, nil
 }
 
-func (of *overwriteFiles) deletedEntries() ([]iceberg.ManifestEntry, error) {
+func (of *overwriteFiles) deletedEntries(ctx context.Context) ([]iceberg.ManifestEntry, error) {
 	// determine if we need to record any deleted entries
 	//
 	// with a full overwrite all the entries are considered deleted
@@ -240,7 +240,7 @@ func (of *overwriteFiles) deletedEntries() ([]iceberg.ManifestEntry, error) {
 
 	nWorkers := config.EnvConfig.MaxWorkers
 	finalResult := make([]iceberg.ManifestEntry, 0, len(previousManifests))
-	for entries, err := range tblutils.MapExec(context.TODO(), nWorkers, slices.Values(previousManifests), getEntries) {
+	for entries, err := range tblutils.MapExec(ctx, nWorkers, slices.Values(previousManifests), getEntries) {
 		if err != nil {
 			return nil, err
 		}
@@ -531,8 +531,8 @@ func (sp *snapshotProducer) fetchManifestEntry(m iceberg.ManifestFile, discardDe
 	return m.FetchEntries(sp.io, discardDeleted)
 }
 
-func (sp *snapshotProducer) manifests() (_ []iceberg.ManifestFile, err error) {
-	deleted, err := sp.deletedEntries()
+func (sp *snapshotProducer) manifests(ctx context.Context) (_ []iceberg.ManifestFile, err error) {
+	deleted, err := sp.deletedEntries(ctx)
 	if err != nil {
 		return nil, err
 	}
@@ -703,8 +703,8 @@ func (sp *snapshotProducer) summary(props iceberg.Properties) (Summary, error) {
 	}, previousSummary)
 }
 
-func (sp *snapshotProducer) commit() (_ []Update, _ []Requirement, err error) {
-	newManifests, err := sp.manifests()
+func (sp *snapshotProducer) commit(ctx context.Context) (_ []Update, _ []Requirement, err error) {
+	newManifests, err := sp.manifests(ctx)
 	if err != nil {
 		return nil, nil, err
 	}
diff --git a/table/snapshot_producers_test.go b/table/snapshot_producers_test.go
index 96791b13..1a710435 100644
--- a/table/snapshot_producers_test.go
+++ b/table/snapshot_producers_test.go
@@ -197,7 +197,7 @@ func TestCommitV3RowLineage(t *testing.T) {
 	df := newTestDataFile(t, spec, "file://data.parquet", nil)
 	sp.appendDataFile(df)
 
-	updates, reqs, err := sp.commit()
+	updates, reqs, err := sp.commit(context.Background())
 	require.NoError(t, err, "commit should succeed")
 	require.Len(t, updates, 2, "expected AddSnapshot and SetSnapshotRef updates")
 	addSnap, ok := updates[0].(*addSnapshotUpdate)
@@ -228,7 +228,7 @@ func TestCommitV3RowLineageTwoSequentialCommits(t *testing.T) {
 	// First commit: new table, append one file (1 row).
 	sp1 := newFastAppendFilesProducer(OpAppend, txn, memIO, nil, nil)
 	sp1.appendDataFile(newTestDataFile(t, spec, "file://data-1.parquet", nil))
-	updates1, reqs1, err := sp1.commit()
+	updates1, reqs1, err := sp1.commit(context.Background())
 	require.NoError(t, err, "first commit should succeed")
 	addSnap1, ok := updates1[0].(*addSnapshotUpdate)
 	require.True(t, ok)
@@ -246,7 +246,7 @@ func TestCommitV3RowLineageTwoSequentialCommits(t *testing.T) {
 	txn2.meta.formatVersion = 3
 	sp2 := newFastAppendFilesProducer(OpAppend, txn2, memIO, nil, nil)
 	sp2.appendDataFile(newTestDataFile(t, spec, "file://data-2.parquet", nil))
-	updates2, reqs2, err := sp2.commit()
+	updates2, reqs2, err := sp2.commit(context.Background())
 	require.NoError(t, err, "second commit should succeed")
 	addSnap2, ok := updates2[0].(*addSnapshotUpdate)
 	require.True(t, ok)
@@ -272,7 +272,7 @@ func TestCommitV3RowLineageDeltaIncludesExistingRows(t *testing.T) {
 	// First commit: one file (1 row).
 	sp1 := newFastAppendFilesProducer(OpAppend, txn, memIO, nil, nil)
 	sp1.appendDataFile(newTestDataFile(t, spec, "file://data-1.parquet", nil))
-	updates1, reqs1, err := sp1.commit()
+	updates1, reqs1, err := sp1.commit(context.Background())
 	require.NoError(t, err, "first commit should succeed")
 	err = txn.apply(updates1, reqs1)
 	require.NoError(t, err)
@@ -291,7 +291,7 @@ func TestCommitV3RowLineageDeltaIncludesExistingRows(t *testing.T) {
 	txn2.meta.props[ManifestMinMergeCountKey] = "2"
 	sp2 := newMergeAppendFilesProducer(OpAppend, txn2, memIO, nil, nil)
 	sp2.appendDataFile(newTestDataFile(t, spec, "file://data-2.parquet", nil))
-	updates2, reqs2, err := sp2.commit()
+	updates2, reqs2, err := sp2.commit(context.Background())
 	require.NoError(t, err, "second commit (merge) should succeed")
 	addSnap2, ok := updates2[0].(*addSnapshotUpdate)
 	require.True(t, ok)
@@ -356,7 +356,7 @@ func TestCommitV3RowLineagePersistsManifestFirstRowID(t *testing.T) {
 	// Use multi-row files to make row-range starts obvious.
 	sp1 := newFastAppendFilesProducer(OpAppend, txn, memIO, nil, nil)
 	sp1.appendDataFile(newTestDataFileWithCount(t, spec, "file://data-1.parquet", nil, 3))
-	updates1, reqs1, err := sp1.commit()
+	updates1, reqs1, err := sp1.commit(context.Background())
 	require.NoError(t, err, "first commit should succeed")
 	addSnap1, ok := updates1[0].(*addSnapshotUpdate)
 	require.True(t, ok, "first update must be AddSnapshot")
@@ -378,7 +378,7 @@ func TestCommitV3RowLineagePersistsManifestFirstRowID(t *testing.T) {
 	txn2.meta.formatVersion = 3
 	sp2 := newFastAppendFilesProducer(OpAppend, txn2, memIO, nil, nil)
 	sp2.appendDataFile(newTestDataFileWithCount(t, spec, "file://data-2.parquet", nil, 5))
-	updates2, _, err := sp2.commit()
+	updates2, _, err := sp2.commit(context.Background())
 	require.NoError(t, err, "second commit should succeed")
 	addSnap2, ok := updates2[0].(*addSnapshotUpdate)
 	require.True(t, ok, "first update must be AddSnapshot")
@@ -401,7 +401,7 @@ func TestSnapshotProducerManifestsClosesWriterOnError(t *testing.T) {
 	sp.appendDataFile(newTestDataFile(t, spec, "file://data-1.parquet", validPartition))
 	sp.appendDataFile(newTestDataFile(t, spec, "file://data-2.parquet", nil))
 
-	_, err := sp.manifests()
+	_, err := sp.manifests(context.Background())
 	require.ErrorIs(t, err, errLimitedWrite)
 }
 
@@ -602,7 +602,7 @@ func TestManifestWriterClosesUnderlyingFile(t *testing.T) {
 	df := newTestDataFile(t, spec, "file://data-1.parquet", nil)
 	sp.appendDataFile(df)
 
-	manifests, err := sp.manifests()
+	manifests, err := sp.manifests(context.Background())
 	require.NoError(t, err, "manifests should succeed")
 	require.Len(t, manifests, 1, "should have one manifest")
 
@@ -709,7 +709,7 @@ func (e *errorOnDeletedEntries) existingManifests() ([]iceberg.ManifestFile, err
 	return nil, nil
 }
 
-func (e *errorOnDeletedEntries) deletedEntries() ([]iceberg.ManifestEntry, error) {
+func (e *errorOnDeletedEntries) deletedEntries(_ context.Context) ([]iceberg.ManifestEntry, error) {
 	if e.waitForWriter != nil {
 		select {
 		case <-e.waitForWriter:
@@ -769,7 +769,7 @@ func TestManifestsClosesWriterWhenDeletedEntriesFails(t *testing.T) {
 	done := make(chan struct{})
 	var manifestsErr error
 	go func() {
-		_, manifestsErr = sp.manifests()
+		_, manifestsErr = sp.manifests(context.Background())
 		close(done)
 	}()
 
diff --git a/table/transaction.go b/table/transaction.go
index 66f8c74f..c9c6688b 100644
--- a/table/transaction.go
+++ b/table/transaction.go
@@ -335,7 +335,7 @@ func (t *Transaction) Append(ctx context.Context, rdr array.RecordReader, snapsh
 		appendFiles.appendDataFile(df)
 	}
 
-	updates, reqs, err := appendFiles.commit()
+	updates, reqs, err := appendFiles.commit(ctx)
 	if err != nil {
 		return err
 	}
@@ -434,7 +434,7 @@ func (t *Transaction) ReplaceDataFiles(ctx context.Context, filesToDelete, files
 		updater.appendDataFile(dataFile)
 	}
 
-	updates, reqs, err := updater.commit()
+	updates, reqs, err := updater.commit(ctx)
 	if err != nil {
 		return err
 	}
@@ -613,7 +613,7 @@ func (t *Transaction) AddDataFiles(ctx context.Context, dataFiles []iceberg.Data
 		appendFiles.appendDataFile(df)
 	}
 
-	updates, reqs, err := appendFiles.commit()
+	updates, reqs, err := appendFiles.commit(ctx)
 	if err != nil {
 		return err
 	}
@@ -725,7 +725,7 @@ func (t *Transaction) ReplaceDataFilesWithDataFiles(ctx context.Context, filesTo
 		updater.appendDataFile(df)
 	}
 
-	updates, reqs, err := updater.commit()
+	updates, reqs, err := updater.commit(ctx)
 	if err != nil {
 		return err
 	}
@@ -814,7 +814,7 @@ func (t *Transaction) AddFiles(ctx context.Context, filePaths []string, snapshot
 		updater.appendDataFile(dataFile)
 	}
 
-	updates, reqs, err := updater.commit()
+	updates, reqs, err := updater.commit(ctx)
 	if err != nil {
 		return err
 	}
@@ -940,7 +940,7 @@ func (t *Transaction) Overwrite(ctx context.Context, rdr array.RecordReader, sna
 		updater.appendDataFile(df)
 	}
 
-	updates, reqs, err := updater.commit()
+	updates, reqs, err := updater.commit(ctx)
 	if err != nil {
 		return err
 	}
@@ -1100,7 +1100,7 @@ func (t *Transaction) Delete(ctx context.Context, filter iceberg.BooleanExpressi
 		return fmt.Errorf("unsupported write mode: '%s'", writeDeleteMode)
 	}
 
-	updates, reqs, err := updater.commit()
+	updates, reqs, err := updater.commit(ctx)
 	if err != nil {
 		return err
 	}