This is an automated email from the ASF dual-hosted git repository.
laskoviymishka 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 a9e2cc329 fix(table): report concurrent DV conflict as
ErrConflictingDeleteFiles (#2598)
a9e2cc329 is described below
commit a9e2cc32942d70e8757de904bafd87771f8dc0b6
Author: Akriti <[email protected]>
AuthorDate: Mon Nov 16 20:22:59 2026 +0530
fix(table): report concurrent DV conflict as ErrConflictingDeleteFiles
(#2598)
* report concurrent DV conflict as ErrConflictingDeleteFiles
* address review: share concurrent DV check, assert reload count, add
compatibility note
---
table/conflict_validation.go | 24 ++++++++++++++++++++++++
table/row_delta.go | 24 ++++++++----------------
table/row_delta_test.go | 13 ++++++++++++-
table/transaction_delete.go | 17 +----------------
website/src/releases.md | 1 +
5 files changed, 46 insertions(+), 33 deletions(-)
diff --git a/table/conflict_validation.go b/table/conflict_validation.go
index 597b39830..1800f06c1 100644
--- a/table/conflict_validation.go
+++ b/table/conflict_validation.go
@@ -596,6 +596,30 @@ func validateDataFilesExist(cc *conflictContext,
referencedPaths []string) error
return dataFilesMissingError(missing, "missing")
}
+// validateNoConcurrentDVs returns an error wrapping ErrConflictingDeleteFiles
+// if a concurrently committed snapshot added a deletion vector for a data file
+// in targets. hint ends the error message. Errors reading the concurrent
+// snapshots' manifests are returned without ErrConflictingDeleteFiles.
+func validateNoConcurrentDVs(cc *conflictContext, targets map[string]struct{},
hint string) error {
+ if len(targets) == 0 {
+ return nil
+ }
+
+ return cc.forEachAddedEntry(iceberg.ManifestContentDeletes, func(snap
Snapshot, entry iceberg.ManifestEntry) error {
+ df := entry.DataFile()
+ ref := explicitReferencedDataFile(df)
+ if !IsDeletionVector(df) || ref == "" {
+ return nil
+ }
+ if _, ok := targets[ref]; ok {
+ return fmt.Errorf("%w: cannot add a deletion vector for
data file %s: concurrent snapshot %d committed a live deletion vector %s for
it; %s",
+ ErrConflictingDeleteFiles, ref,
snap.SnapshotID, df.FilePath(), hint)
+ }
+
+ return nil
+ })
+}
+
// headDataFiles returns the paths in referenced that a delete staged next
must still
// find live on the branch head when the transaction commits
(validateDataFilesExist).
// It replays, oldest first, the data files added and removed by the staged
snapshots
diff --git a/table/row_delta.go b/table/row_delta.go
index f4b1b83a4..1fd8689e8 100644
--- a/table/row_delta.go
+++ b/table/row_delta.go
@@ -720,6 +720,12 @@ func (rd *RowDelta) validate(cc *conflictContext,
referenced []string) error {
// this delta also adds a DV for would strand two live DVs on one data file —
// reject. A removal-carrying delta is non-replayable (see RemoveDeletes), so a
// retry never has removals to reconcile against the concurrent DV here.
+// A conflict is reported as an error wrapping ErrConflictingDeleteFiles, and
+// so ErrCommitFailed, which makes Transaction.Commit fail with
+// ErrTransactionUnusable. To resolve it, build a new row delta from the
+// reloaded table that adds a DV holding both DVs' positions and removes the
+// concurrent DV with RemoveDeletes. Errors reading the concurrent snapshots'
+// manifests do not wrap ErrConflictingDeleteFiles.
func (rd *RowDelta) validateNoConcurrentReplacedDVs(cc *conflictContext) error
{
addedRefs := make(map[string]struct{}, len(rd.delFiles))
for _, f := range rd.delFiles {
@@ -727,23 +733,9 @@ func (rd *RowDelta) validateNoConcurrentReplacedDVs(cc
*conflictContext) error {
addedRefs[ref] = struct{}{}
}
}
- if len(addedRefs) == 0 {
- return nil
- }
- return cc.forEachAddedEntry(iceberg.ManifestContentDeletes, func(snap
Snapshot, entry iceberg.ManifestEntry) error {
- df := entry.DataFile()
- ref := explicitReferencedDataFile(df)
- if !IsDeletionVector(df) || ref == "" {
- return nil
- }
- if _, ok := addedRefs[ref]; ok {
- return fmt.Errorf("cannot add a deletion vector for
data file %s: concurrent snapshot %d committed a live deletion vector %s for
it; reload the table and rewrite the DV to supersede the concurrent one,
removing the superseded DV in the same row delta",
- ref, snap.SnapshotID, df.FilePath())
- }
-
- return nil
- })
+ return validateNoConcurrentDVs(cc, addedRefs,
+ "reload the table and rewrite the DV to supersede the
concurrent one, removing the superseded DV in the same row delta")
}
// Operation returns the snapshot operation type that will be used when
diff --git a/table/row_delta_test.go b/table/row_delta_test.go
index 51a9f221c..3a38b39f1 100644
--- a/table/row_delta_test.go
+++ b/table/row_delta_test.go
@@ -1797,7 +1797,8 @@ func TestRowDeltaFastAppendRejectsDuplicateAddedDVs(t
*testing.T) {
// Condition: Writer A adds a DV for data file D; a concurrent writer commits
// the first DV for D before A's commit lands, forcing A to retry.
// Assertion: A's commit fails on the retry (after one refresh, before a second
-// commit attempt) with the concurrent-DV conflict error.
+// commit attempt) with ErrConflictingDeleteFiles, and the transaction becomes
+// unusable.
func TestRowDeltaRejectsConcurrentFirstDVOnRetry(t *testing.T) {
localFS := func(context.Context) (iceio.IO, error) { return
iceio.LocalFS{}, nil }
@@ -1868,12 +1869,22 @@ func TestRowDeltaRejectsConcurrentFirstDVOnRetry(t
*testing.T) {
_, err = txA.Commit(t.Context())
require.Error(t, err)
+ assert.ErrorIs(t, err, table.ErrConflictingDeleteFiles)
+ assert.ErrorIs(t, err, table.ErrCommitFailed)
+ assert.ErrorIs(t, err, table.ErrTransactionUnusable)
assert.Contains(t, err.Error(), "concurrent snapshot")
assert.Contains(t, err.Error(), dataPath)
assert.Equal(t, int32(1), catA.loadTableCalls.Load(),
"the commit must refresh once for the retry before rejecting")
assert.Equal(t, int32(1), catA.commitTableCalls.Load(),
"the validator must reject on the refreshed retry, before a
second commit attempt")
+
+ // The conflict leaves the transaction unusable: committing it again
fails
+ // before reaching the catalog.
+ _, err = txA.Commit(t.Context())
+ require.ErrorIs(t, err, table.ErrTransactionUnusable)
+ assert.Equal(t, int32(1), catA.loadTableCalls.Load())
+ assert.Equal(t, int32(1), catA.commitTableCalls.Load())
}
func writeRowDeltaDataFile(t *testing.T, tbl *table.Table, path string, ids
...int64) iceberg.DataFile {
diff --git a/table/transaction_delete.go b/table/transaction_delete.go
index b14d90dca..5fdb2cdec 100644
--- a/table/transaction_delete.go
+++ b/table/transaction_delete.go
@@ -215,23 +215,8 @@ func (t *Transaction) performMergeOnReadDeletion(ctx
context.Context, snapshotPr
if err := validateDataFilesExist(cc,
referenced); err != nil {
return err
}
- if len(dvTargets) == 0 {
- return nil
- }
-
- return
cc.forEachAddedEntry(iceberg.ManifestContentDeletes, func(snap Snapshot, entry
iceberg.ManifestEntry) error {
- file := entry.DataFile()
- ref := explicitReferencedDataFile(file)
- if !IsDeletionVector(file) || ref == ""
{
- return nil
- }
- if _, ok := dvTargets[ref]; ok {
- return fmt.Errorf("%w: cannot
add a deletion vector for data file %s: concurrent snapshot %d committed a live
deletion vector %s for it; reload the table and retry the delete",
-
ErrConflictingDeleteFiles, ref, snap.SnapshotID, file.FilePath())
- }
- return nil
- })
+ return validateNoConcurrentDVs(cc, dvTargets,
"reload the table and retry the delete")
})
}
}
diff --git a/website/src/releases.md b/website/src/releases.md
index b69d0f587..a7ca2f091 100644
--- a/website/src/releases.md
+++ b/website/src/releases.md
@@ -94,6 +94,7 @@ Per-release notes (highlights, breaking changes,
contributors) are published on
- **Retries preserve staged update order.** An append staged after
`RollbackToSnapshot` stays on the rollback target after a retry or resumed
`Commit`. If a staged update cannot apply after refresh, the transaction ends
with `table.ErrTransactionUnusable`. For example, `UpgradeFormatVersion` cannot
apply if a peer has committed a higher format version. The error preserves its
cause and also matches `table.ErrCommitFailed` if that cause is a conflict.
Previously, for transactions without [...]
- **Retries renew snapshot timestamps.** A retry or resumed `Commit` stamps
each snapshot it replays from a staged write with the current time, at least
one millisecond after its parent, as Java's `SnapshotProducer` does. A snapshot
staged more than a minute before a peer's commit no longer fails the retry. The
committed timestamp is the time of the attempt that lands, so an
`ExpireSnapshots` staged after the write in the same transaction keeps that
snapshot when the commit retries.
- **Snapshot expiration now tolerates concurrent ref changes.** If a
concurrent commit moves a ref that the expiry read, a retry or later `Commit`
replans instead of failing with `table.ErrCommitFailed`. The committed expiry
can differ from `Transaction.StagedTable`. See [Snapshot
expiration](./concurrent-writes.md#snapshot-expiration) for cases that now fail
with `table.ErrTransactionUnusable`.
+- **RowDelta reports a concurrent deletion vector as a commit conflict.** If a
concurrent commit adds a deletion vector for a data file that a `RowDelta` also
adds one for, `Transaction.Commit` now fails with an error matching
`table.ErrConflictingDeleteFiles`, `table.ErrCommitFailed` and
`table.ErrTransactionUnusable`, and the transaction cannot be committed again.
Previously, the error matched none of them and the transaction stayed usable.
To resolve the conflict, reload the table and [...]
- **Schema JSON constructor uses the Go initialism.** Replace
`iceberg.NewSchemaFromJsonFields` with `iceberg.NewSchemaFromJSONFields`.
- **AWS identifiers use the Go initialism.** `glue.AwsProperties`,
`glue.WithAwsConfig` and `glue.WithAwsProperties` become `glue.AWSProperties`,
`glue.WithAWSConfig` and `glue.WithAWSProperties`; `sigv4.WithAwsConfig`
becomes `sigv4.WithAWSConfig`; `utils.WithAwsConfig` and `utils.GetAwsConfig`
become `utils.WithAWSConfig` and `utils.GetAWSConfig`; and
`config.CatalogConfig.AwsProfile` becomes `AWSProfile`. The `aws-profile` YAML
key is unchanged.
- **KMS factory registration now takes a context.** Change
`encryption.KMSFactory` implementations to accept `(context.Context,
map[string]string)` instead of only properties, and call
`encryption.LoadKeyManagementClient(ctx, props)` instead of
`LoadKeyManagementClient(props)`. The existing global `RegisterKMS`,
`UnregisterKMS`, and `GetRegisteredKMSNames` functions still use the default
registry; `RegisterKMS` still panics for invalid registrations. Use
`encryption.MustRegisterKMS` for [...]