Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Snapshot 123 is not an ancestor of 456 when running DELETE query on Trino (parallel writes) #10013

Open
paul-bormans-pcgw opened this issue Nov 29, 2024 · 4 comments · May be fixed by #10033

Comments

@paul-bormans-pcgw
Copy link

What happened

Every so many seconds we append new data to a Table using pyIceberg (using Arrow tables).

On the background we run some Table maintenance operations; specifically removing old data is important (since we have limited space available). We do this using Trino:

DELETE FROM pack WHERE epoch_timestamp_tz <= timestamp '2024-11-29 13:15' AND timestampns < 1.7328861183132278e+18

Now this query takes a few minutes to complete but in the end it fails to create a new snapshot:

java.lang.IllegalArgumentException: Snapshot 3398968223100354057 is not an ancestor of 5174469298448934675
	at org.apache.iceberg.relocated.com.google.common.base.Preconditions.checkArgument(Preconditions.java:430)
	at org.apache.iceberg.BaseRowDelta.validate(BaseRowDelta.java:113)
	at org.apache.iceberg.SnapshotProducer.apply(SnapshotProducer.java:235)
	at org.apache.iceberg.SnapshotProducer.lambda$commit$2(SnapshotProducer.java:386)

I'm sure it's related to the parallel write operations, because when I stop the ingest activities (Trino is then the only remaining writer); the query succeeds.

I know with use of Nessie you do not have table history (can't see older snapshots) since Nessie maintains these are catalog level instead; i'm wondering if this has anything to do with my finding?

Or are there additional iceberg configuration to set?
Can I extend the query to claim exclusive write access to the Table?

How to reproduce it

  1. Table is created in pyIceberg:
catalog.create_table(
                identifier=f"{self.namespace}.{table_name}",
                schema=pt.schema,
                properties={
                    "gc.enabled": True,
})
Also partition specs are added:

update.add_field(
                    source_column_name="epoch_timestamp_tz",
                    transform=HourTransform(),
                    partition_field_name="epoch_hours",
                )
  1. append Arrow tables every second
  2. run trino query which take a few minutes to complete.

Nessie server type (docker/uber-jar/built from source) and version

docker: quay.io/projectnessie/nessie:0.100.1

Client type (Ex: UI/Spark/pynessie ...) and version

PyIceberg + Trino

Additional information

No response

@dimas-b
Copy link
Member

dimas-b commented Nov 29, 2024

@paul-bormans-pcgw : since PyIceberg is involved, I assume the catalog interactions were done via the Iceberg REST API. Could you please confirm this (especially with Trino)?

@paul-bormans-pcgw
Copy link
Author

Hello @dimas-b,

You are correct; iceberg connector configuration is as follows:

connector.name=iceberg
fs.native-s3.enabled=true
iceberg.catalog.type=rest
iceberg.rest-catalog.security=NONE
iceberg.rest-catalog.uri=http\://nessie\:19120/iceberg/
iceberg.rest-catalog.vended-credentials-enabled=false
s3.endpoint=http\://minio\:9000/
s3.path-style-access=true
s3.region=us-east-1
s3.aws-access-key=minioadmin
s3.aws-secret-key=minioadmin

This is btw the Nessie generated config:

NESSIE_BASE_URL="http://127.0.0.1:19120/"
curl "${NESSIE_BASE_URL}/iceberg-ext/v1/client-template/trino?format=static"

Paul

@snazy
Copy link
Member

snazy commented Dec 2, 2024

Looks related/similar to #9969

@paul-bormans-pcgw
Copy link
Author

Please confirm, you mean that I should run this DELETE query using catalog type="nessie"? (and not over type="rest")?
Also I'm pretty sure behind this first issue with ancestor not found, there is an issue with concurrent writers (that however is not a Nessie problem i think but an Iceberg configuration thing...).
Paul

snazy added a commit to snazy/nessie that referenced this issue Dec 3, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
snazy added a commit to snazy/nessie that referenced this issue Dec 3, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
snazy added a commit to snazy/nessie that referenced this issue Dec 3, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
snazy added a commit to snazy/nessie that referenced this issue Dec 3, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
snazy added a commit to snazy/nessie that referenced this issue Dec 3, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
snazy added a commit to snazy/nessie that referenced this issue Dec 3, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
snazy added a commit to snazy/nessie that referenced this issue Dec 4, 2024
The current behavior of Nessie's Iceberg REST is to return only the most recent Iceberg snapshot. However, this seems to conflict with some Iceberg operations, which are not only maintenance operations, but rather related to "merge on read" / (equality) deletes.

This change changes Nessie's behavior by returning older snapshots from a load-table and update-table operations.

Register-table operation however do not change, because only the latest snapshot is actually imported. The behavior does change by returning an error if the table to be registered has more than 1 snapshots.

Fixes projectnessie#10013
Fixes projectnessie#9969
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants