Skip to content

Concurrently re-applying the same changes to a View fails #15008

@nastra

Description

@nastra

Apache Iceberg version

None

Query engine

None

Please describe the bug 🐞

The test in #14334 uncovered an edge case where the same view change is applied twice and fails with

org.apache.iceberg.exceptions.ValidationException: Cannot set last added schema: no schema has been added
	at org.apache.iceberg.exceptions.ValidationException.check(ValidationException.java:49)
	at org.apache.iceberg.view.ViewMetadata$Builder.addVersionInternal(ViewMetadata.java:297)
	at org.apache.iceberg.view.ViewMetadata$Builder.addVersion(ViewMetadata.java:277)
	at org.apache.iceberg.MetadataUpdate$AddViewVersion.applyTo(MetadataUpdate.java:508)
	at org.apache.iceberg.rest.CatalogHandlers.lambda$commit$11(CatalogHandlers.java:624)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at org.apache.iceberg.rest.CatalogHandlers.lambda$commit$12(CatalogHandlers.java:624)

This is due to our internal state tracking of lastAddedSchemaId, which is then assumed to be set when adding the view version and checking

if (version.schemaId() == LAST_ADDED) {
  ValidationException.check(lastAddedSchemaId != null, "Cannot set last added schema: no schema has been added");
  version = ImmutableViewVersion.builder().from(version).schemaId(lastAddedSchemaId).build();
}

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions