Skip to content

Core, AWS: Fix REST catalog hanging on permission errors - #17400

Open
sqd wants to merge 1 commit into
apache:mainfrom
sqd:oss_permission_hang
Open

Core, AWS: Fix REST catalog hanging on permission errors#17400
sqd wants to merge 1 commit into
apache:mainfrom
sqd:oss_permission_hang

Conversation

@sqd

@sqd sqd commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Refreshing table or view metadata retries any read failure up to 20 times with exponential backoff (about 90 seconds) unless it is a NotFoundException. A permission error is permanent, so retrying can never succeed and only delays surfacing the real failure.

Behind a REST catalog, the server holds the loadTable request open for the whole retry loop, so clients hit their socket read timeout first and report SocketTimeoutException while the actual cause (for example an HDFS "Permission denied" on the metadata file) is only visible in server logs. Stuck requests also pin server worker threads, causing timeouts for unrelated tables.

Translate access-denied errors into ForbiddenException at the read boundary - HadoopFileIO on AccessControlException and S3FileIO on S3Exception with status 403 - and stop metadata refresh retries on ForbiddenException. RESTCatalogAdapter already maps ForbiddenException to HTTP 403 and REST clients map 403 back to ForbiddenException, so callers now receive the underlying permission error immediately.


assertThatThrownBy(() -> s3InputStream.readFully(0, new byte[0]))
.isInstanceOf(ForbiddenException.class)
.hasMessageContaining("Access Denied");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we validate message content here? The exception message could change in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not testing what exact words are returned from awssdk. This is testing that whatever the library returns will get propagated so the error is clearer to the client. I extrapolated this to a const to make the intention clearer.

import org.apache.iceberg.io.FileIO;
import org.junit.jupiter.api.Test;

public class TestBaseMetastoreTableOperations {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class name is very general. But you are only testing the retries on transient error and un-recoverable errors.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I'll change this.

Refreshing table or view metadata retries any read failure up to 20
times with exponential backoff (about 90 seconds) unless it is a
NotFoundException. A permission error is permanent, so retrying can
never succeed and only delays surfacing the real failure.

Behind a REST catalog, the server holds the loadTable request open
for the whole retry loop, so clients hit their socket read timeout
first and report SocketTimeoutException while the actual cause
(for example an HDFS "Permission denied" on the metadata file) is
only visible in server logs. Stuck requests also pin server worker
threads, causing timeouts for unrelated tables.

Translate access-denied errors into ForbiddenException at the read
boundary - HadoopFileIO on AccessControlException and S3FileIO on
S3Exception with status 403 - and stop metadata refresh retries on
ForbiddenException. RESTCatalogAdapter already maps
ForbiddenException to HTTP 403 and REST clients map 403 back to
ForbiddenException, so callers now receive the underlying permission
error immediately.
@sqd
sqd force-pushed the oss_permission_hang branch from c0d08ea to cc857d3 Compare July 29, 2026 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants