Skip to content

Propagate access control exception#27862

Open
Chaho12 wants to merge 1 commit intotrinodb:masterfrom
Chaho12:feature/jyoo/fix-access-control-exception
Open

Propagate access control exception#27862
Chaho12 wants to merge 1 commit intotrinodb:masterfrom
Chaho12:feature/jyoo/fix-access-control-exception

Conversation

@Chaho12
Copy link
Copy Markdown
Member

@Chaho12 Chaho12 commented Jan 6, 2026

Description

Background

This issue occurs when using StorageBasedAuthorizationProvider in Hive Metastore.
In this case, an AccessControlException can be thrown during authorization checks, but the error is not propagated to the client immediately, causing the client to wait until the metastore Thrift timeout expires (default: 10s).

Relevant code:

Fix
This change propagates AccessControlExceptions to the client immediately, avoiding unnecessary waits for the Thrift timeout.

Additional context and related issues

Here is the exception message sent from metastore.

MetaException(message:java.security.AccessControlException: Permission denied: user=..., access=EXECUTE, inode="/user/...":...:services:drwx------
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:399)
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkTraverse(FSPermissionChecker.java:315)
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:242)
	at org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer$RangerAccessControlEnforcer.checkDefaultEnforcer(RangerHdfsAuthorizer.java:589)
	at org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer$RangerAccessControlEnforcer.checkPermission(RangerHdfsAuthorizer.java:377)
	at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:193)
	at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1877)
	at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPermission(FSDirectory.java:1861)
	at org.apache.hadoop.hdfs.server.namenode.FSDirectory.checkPathAccess(FSDirectory.java:1811)
	at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkAccess(FSNamesystem.java:8048)
	at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.checkAccess(NameNodeRpcServer.java:2234)
	at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.checkAccess(ClientNamenodeProtocolServerSideTranslatorPB.java:1659)
	at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
	at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:523)
	at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:991)
	at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:872)
	at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:818)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.Subject.doAs(Subject.java:422)
	at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729)
	at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2678)
)

Release notes

(x) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

## Section
* Fix some things. ({issue}`issuenumber`)

@github-actions github-actions bot added the hive Hive connector label Jan 6, 2026
@Chaho12 Chaho12 force-pushed the feature/jyoo/fix-access-control-exception branch from 299a369 to 8764b94 Compare January 6, 2026 07:07
addSuppressed(e, suppressedExceptions);
throw e;
}
for (Class<? extends Exception> clazz : stopOnExceptions) {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

stopOnExceptions passed on here was

0 = {Class@37632} "class io.trino.spi.TrinoException"
1 = {Class@42658} "class io.trino.hive.thrift.metastore.NoSuchObjectException"
2 = {Class@42226} "class java.lang.NullPointerException"
3 = {Class@41494} "class java.lang.IllegalStateException"
4 = {Class@42222} "class java.lang.IllegalArgumentException"

@Chaho12
Copy link
Copy Markdown
Member Author

Chaho12 commented Jan 6, 2026

Ps. Hive recently sent a PR (Hive 4.3) to handles similar issue in "Propagate HiveAccessControlException to HiveCatalog"

It seems that Hive 4.3 will return in ForbiddenException type, so maybe we can add that when checking isAccessControlException

@Chaho12 Chaho12 changed the title Fix access control exception Propagate access control exception Jan 6, 2026
@Chaho12 Chaho12 requested a review from raunaqmorarka January 7, 2026 14:41
@Chaho12
Copy link
Copy Markdown
Member Author

Chaho12 commented Jan 7, 2026

Can you take a look at this? @raunaqmorarka

{
// Check the exception message and cause chain for AccessControlException
// e.g. io.trino.hive.thrift.metastore.MetaException:
// org.apache.hadoop.security.AccessControlException: Permission 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.

this could be simplified to:

Throwables.getCausalChain(exception)
                .stream()
                .map(Throwable::toString)
                .anyMatch(message -> message != null && message.contains("AccessControlException"));

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Simplified :)

@Chaho12 Chaho12 force-pushed the feature/jyoo/fix-access-control-exception branch from 8764b94 to 603d8f5 Compare January 7, 2026 23:18
@Chaho12 Chaho12 requested a review from wendigo January 7, 2026 23:22
@chenjian2664
Copy link
Copy Markdown
Contributor

cc @Praveen2112

@Chaho12 Chaho12 requested a review from Praveen2112 January 13, 2026 05:16
@Chaho12
Copy link
Copy Markdown
Member Author

Chaho12 commented Jan 23, 2026

It would be great if this PR is included in next release.

return Throwables.getCausalChain(exception)
.stream()
.map(Throwable::toString)
.anyMatch(message -> message != null && message.contains("AccessControlException"));
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.

Just an idea : maybe we could use the class to check if it is a AccessControlException, also since the class is marked deprecated, so could use the SecurityException instead?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You mean do this instead of contains?

  • err.getClass().getName().equals("org.apache.hadoop.fs.permission.AccessControlException")) {

Seems like it is superseded by "org.apache.hadoop.security.AccessControlException"
Nonetheless, depending on Hive version, any of the class name could occur, so we could check for both class

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 5, 2026

This pull request has gone a while without any activity. Ask for help on #core-dev on Trino slack.

@github-actions github-actions bot added the stale label Mar 5, 2026
@github-actions
Copy link
Copy Markdown

Closing this pull request, as it has been stale for six weeks. Feel free to re-open at any time.

@github-actions github-actions bot closed this Mar 27, 2026
@wendigo wendigo reopened this Mar 27, 2026
@Chaho12
Copy link
Copy Markdown
Member Author

Chaho12 commented Mar 30, 2026

Any furthere comments? I can rebase it later

@github-actions github-actions bot removed the stale label Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hive Hive connector

Development

Successfully merging this pull request may close these issues.

3 participants