lakekeeper: Trino's `expire_snapshot` Not Deleting S3 Files and Raise Error (Soft-Deletion Disabled)
Describe the bug I’m encountering potential issues with deleting underlying files in S3 using maintenance procedures like expire_snapshots in Trino. While Spark seems to handle this correctly under different soft-deletion configurations, Trino exhibits inconsistent behavior.
For Spark:
- Soft-deletion disabled: Spark’s expire_snapshots successfully deletes both metadata and the corresponding files without requiring any specific S3 deletion configurations.
- Soft-deletion enabled: Spark also manages to delete both metadata and files when the
s3.delete-enabled: trueconfiguration is explicitly set in the client. And it works.
However, with Trino, I’m experiencing a problem. Even when soft-deletion is disabled, Trino fails to remove the underlying files in S3 during the expire_snapshots process. Note, the metadata snapshots are deleted as expected, but the actual data files remain in S3, and raise errors.
Message error:
Caused by: java.sql.SQLException: Query failed (#20250429_025633_00022_wwef4): Failed to delete files during snapshot expiration
at io.trino.jdbc.ResultUtils.resultsException(ResultUtils.java:33)
at io.trino.jdbc.AsyncResultIterator.lambda$new$1(AsyncResultIterator.java:93)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: io.trino.spi.TrinoException: Failed to delete files during snapshot expiration
at io.trino.plugin.iceberg.IcebergMetadata.executeExpireSnapshots(IcebergMetadata.java:2188)
at io.trino.plugin.iceberg.IcebergMetadata.executeTableExecute(IcebergMetadata.java:2087)
at io.trino.plugin.base.classloader.ClassLoaderSafeConnectorMetadata.executeTableExecute(ClassLoaderSafeConnectorMetadata.java:217)
at io.trino.tracing.TracingConnectorMetadata.executeTableExecute(TracingConnectorMetadata.java:188)
at io.trino.metadata.MetadataManager.executeTableExecute(MetadataManager.java:370)
at io.trino.tracing.TracingMetadata.executeTableExecute(TracingMetadata.java:238)
at io.trino.operator.SimpleTableExecuteOperator.getOutput(SimpleTableExecuteOperator.java:128)
at io.trino.operator.Driver.processInternal(Driver.java:403)
at io.trino.operator.Driver.lambda$process$8(Driver.java:306)
at io.trino.operator.Driver.tryWithLock(Driver.java:709)
at io.trino.operator.Driver.process(Driver.java:298)
at io.trino.operator.Driver.processForDuration(Driver.java:269)
at io.trino.execution.SqlTaskExecution$DriverSplitRunner.processFor(SqlTaskExecution.java:890)
at io.trino.execution.executor.dedicated.SplitProcessor.run(SplitProcessor.java:77)
at io.trino.execution.executor.dedicated.TaskEntry$VersionEmbedderBridge.lambda$run$0(TaskEntry.java:201)
at io.trino.$gen.Trino_474____20250423_102443_2.run(Unknown Source)
at io.trino.execution.executor.dedicated.TaskEntry$VersionEmbedderBridge.run(TaskEntry.java:202)
at io.trino.execution.executor.scheduler.FairScheduler.runTask(FairScheduler.java:177)
at io.trino.execution.executor.scheduler.FairScheduler.lambda$submit$0(FairScheduler.java:164)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:545)
at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:131)
at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:75)
at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:82)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1095)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:619)
at java.base/java.lang.Thread.run(Thread.java:1447)
Caused by: io.trino.filesystem.TrinoFileSystemException: Error while batch deleting files
at io.trino.filesystem.s3.S3FileSystem.deleteObjects(S3FileSystem.java:213)
at io.trino.filesystem.s3.S3FileSystem.deleteFiles(S3FileSystem.java:177)
at io.trino.filesystem.switching.SwitchingFileSystem.deleteFiles(SwitchingFileSystem.java:94)
at io.trino.filesystem.tracing.TracingFileSystem.lambda$deleteFiles$1(TracingFileSystem.java:89)
at io.trino.filesystem.tracing.Tracing.lambda$withTracing$1(Tracing.java:42)
at io.trino.filesystem.tracing.Tracing.withTracing(Tracing.java:51)
at io.trino.filesystem.tracing.Tracing.withTracing(Tracing.java:41)
at io.trino.filesystem.tracing.TracingFileSystem.deleteFiles(TracingFileSystem.java:89)
at io.trino.filesystem.cache.CacheFileSystem.deleteFiles(CacheFileSystem.java:148)
at io.trino.plugin.iceberg.IcebergMetadata.executeExpireSnapshots(IcebergMetadata.java:2185)
... 25 more
Caused by: software.amazon.awssdk.core.exception.SdkClientException: Unable to load credentials from any of the providers in the chain AwsCredentialsProviderChain(credentialsProviders=[SystemPropertyCredentialsProvider(), EnvironmentVariableCredentialsProvider(), WebIdentityTokenCredentialsProvider(), ProfileCredentialsProvider(profileName=default, profileFile=ProfileFile(sections=[])), ContainerCredentialsProvider(), InstanceProfileCredentialsProvider()]) : [SystemPropertyCredentialsProvider(): Unable to load credentials from system settings. Access key must be specified either via environment variable (AWS_ACCESS_KEY_ID) or system property (aws.accessKeyId)., EnvironmentVariableCredentialsProvider(): Unable to load credentials from system settings. Access key must be specified either via environment variable (AWS_ACCESS_KEY_ID) or system property (aws.accessKeyId)., WebIdentityTokenCredentialsProvider(): Either the environment variable AWS_WEB_IDENTITY_TOKEN_FILE or the javaproperty aws.webIdentityTokenFile must be set., ProfileCredentialsProvider(profileName=default, profileFile=ProfileFile(sections=[])): Profile file contained no credentials for profile 'default': ProfileFile(sections=[]), ContainerCredentialsProvider(): Cannot fetch credentials from container - neither AWS_CONTAINER_CREDENTIALS_FULL_URI or AWS_CONTAINER_CREDENTIALS_RELATIVE_URI environment variables are set., InstanceProfileCredentialsProvider(): Failed to load credentials from IMDS.]
at software.amazon.awssdk.core.exception.SdkClientException$BuilderImpl.build(SdkClientException.java:130)
at software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain.resolveCredentials(AwsCredentialsProviderChain.java:130)
at software.amazon.awssdk.auth.credentials.internal.LazyAwsCredentialsProvider.resolveCredentials(LazyAwsCredentialsProvider.java:45)
at software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider.resolveCredentials(DefaultCredentialsProvider.java:129)
at software.amazon.awssdk.auth.credentials.AwsCredentialsProvider.resolveIdentity(AwsCredentialsProvider.java:54)
at software.amazon.awssdk.services.s3.auth.scheme.internal.S3AuthSchemeInterceptor.lambda$trySelectAuthScheme$6(S3AuthSchemeInterceptor.java:169)
at software.amazon.awssdk.core.internal.util.MetricUtils.reportDuration(MetricUtils.java:80)
at software.amazon.awssdk.services.s3.auth.scheme.internal.S3AuthSchemeInterceptor.trySelectAuthScheme(S3AuthSchemeInterceptor.java:169)
at software.amazon.awssdk.services.s3.auth.scheme.internal.S3AuthSchemeInterceptor.selectAuthScheme(S3AuthSchemeInterceptor.java:87)
at software.amazon.awssdk.services.s3.auth.scheme.internal.S3AuthSchemeInterceptor.beforeExecution(S3AuthSchemeInterceptor.java:67)
at software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain.lambda$beforeExecution$1(ExecutionInterceptorChain.java:59)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
at software.amazon.awssdk.core.interceptor.ExecutionInterceptorChain.beforeExecution(ExecutionInterceptorChain.java:59)
at software.amazon.awssdk.awscore.internal.AwsExecutionContextBuilder.runInitialInterceptors(AwsExecutionContextBuilder.java:254)
at software.amazon.awssdk.awscore.internal.AwsExecutionContextBuilder.invokeInterceptorsAndCreateExecutionContext(AwsExecutionContextBuilder.java:144)
at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.invokeInterceptorsAndCreateExecutionContext(AwsSyncClientHandler.java:67)
at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.lambda$execute$1(BaseSyncClientHandler.java:76)
at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.measureApiCallSuccess(BaseSyncClientHandler.java:182)
at software.amazon.awssdk.core.internal.handler.BaseSyncClientHandler.execute(BaseSyncClientHandler.java:74)
at software.amazon.awssdk.core.client.handler.SdkSyncClientHandler.execute(SdkSyncClientHandler.java:45)
at software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler.execute(AwsSyncClientHandler.java:53)
at software.amazon.awssdk.services.s3.DefaultS3Client.deleteObjects(DefaultS3Client.java:3640)
at io.trino.filesystem.s3.S3FileSystem.deleteObjects(S3FileSystem.java:207)
... 34 more
To Reproduce Steps to reproduce the behavior, preferably starting from one of our docker-compose examples.
- Connect Trino in DBeaver
- Run
expire_snapshotand get errors
Expected behavior
Trino can run expire_snapshot without errors and delete both metadata and files underlying S3 storage
Screenshots
Check number of files and snapshots before executing procedure using Trino
Run expire_snapshot and got errors
Check files and snapshots metadata after executing. Metadata is deleted as expected, but not files
System Information:
- Deployment Type: Heml
- Lakekeeper Version: 0.8.3
- Authentication Provider: Keycloak
- Authorization Provider: OpenFGA
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (2 by maintainers)
After debugging trino for a bit, I’ve found:
S3FileSystem.context.credentialsProviderOverride(src/main/java/io/trino/filesystem/s3/S3FileSystem.java) has as correspondingStaticCredentialsProvider(credentials=AwsSessionCredentials(....))S3FileSystem::delete_objectsthere are two config overrides:After stepping through this in a debugger, it appears that after
.overrideConfiguration(context::applyCredentialProviderOverride)the credential provider is set correctly. After.overrideConfiguration(disableStrongIntegrityChecksums())it’s set to null again which apparently was part of a fix for strong integrity checks:Given all that, my current understanding is that this is a regression in trino introduced to fix issues with signers & strong integrity checks. I’m not sure why, but I cannot build trino locally, it fails on trino-docs. We’ll open an issue at trino.
Once https://github.com/trinodb/trino/pull/25791 is released trino’s expire_snapshots should work. We may have to change default access to vended-credentials as I encountered some errors while testing the 476 + fix image.
After upgrading trino to 475 I can reproduce the credentials error. I’m now trying to understand if it is a regression or if it has been a silent error before. Our example was on trino 467.
Hi @twuebi, My table is quite small(for testing purposes), around 10 rows and 5 snapshots. Btw, my namespace have nearly 50 tables.
Thanks for your respone @c-thiel , I’m also encountering the same keyword error and I’m unsure of the exact cause.
For easier problem tracing, I’m using Ceph RGW.
My config @twuebi , I’m using Trino 474
Lakekeeper v0.8.3 storage conf {"type": "s3", "bucket": "test-sts-bucket", "flavor": "s3-compat", "region": "us-east-2", "endpoint": "https://ceph-rgw.xyz/", "key-prefix": "test-sts-bucket2", "sts-enabled": true, "sts-role-arn": "arn:aws:iam:::role/cephsts", "assume-role-arn": null, "path-style-access": true, "push-s3-delete-disabled": false, "allow-alternative-protocols": false}It still raise error. Following this error, I observed that Trino attempts to use static S3 credentials instead of vended credentials from Lakekeeper to delete S3 files.
Hi @twuebi, Thanks for the detailed information and the code snippet. My table doesn’t have any properties; I’ve left it with the default settings.
In my case, I’ve already test in both soft-deletion disabled/enabled and regardless of
push-s3-delete-disabled=falseorpush-s3-delete-disabled=true, it still get same error. However, when I try to select snapshots after doing this. The metadata snapshots are deleted as expected, but the actual data files remain in S3, and raise errors.(as my image above).Here is the code I use to reproduce the error. Could you please rerun it? I’ve also included an UPDATE operation in this case.