Skip to content

[SPARK-52613][CORE][SQL] Restore printing full stacktrace when HBase/Hive DelegationTokenProvider hit exception#51320

Closed
pan3793 wants to merge 1 commit into
apache:masterfrom
pan3793:SPARK-52613
Closed

[SPARK-52613][CORE][SQL] Restore printing full stacktrace when HBase/Hive DelegationTokenProvider hit exception#51320
pan3793 wants to merge 1 commit into
apache:masterfrom
pan3793:SPARK-52613

Conversation

@pan3793

@pan3793 pan3793 commented Jun 30, 2025

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

After SPARK-35747(3.2.0), Spark stops printing full stacktrace when HBase/Hive/Kafka DelegationTokenProvider hit exceptions.

SPARK-35747 actually makes two changes:

  1. Remove full stacktrace from logs
  2. Guide disabling unused DelegationTokenProvider - If $serviceName is not used, set spark.security.credentials.$serviceName.enabled to false

I think 2 is useful, but 1 is incorrect, this PR logically reverts 1 (changes in KafkaDelegationTokenProvider have been reverted in SPARK-47593(4.0.0))

We recently hit an issue related to HBaseDelegationTokenProvider, the printed error message is

[WARN] [main] HBaseDelegationTokenProvider#94 - Failed to get token from service hbase due to java.lang.reflect.InvocationTargetException. If hbase is not used, set spark.security.credentials.hbase.enabled to false. Retrying to fetch HBase security token with hbase connection parameter.

it makes us think it's related to a classpath issue, but eventually, after we changed the code to print the full stacktrace, we found the root cause is

org.apache.hadoop.hbase.security.AccessDeniedException: Insufficient permissions (user=***/***@***.COM, scope=hbase:meta, params=[table=hbase:meta,],action=EXEC)

Full stacktrace: https://gist.github.com/pan3793/46a3f6b956a7982646e1ee75603a1865

Why are the changes needed?

Improve the diagnosis experience.

Does this PR introduce any user-facing change?

Yes, the user would see rich error messages when HBase/Hive DelegationTokenProvider hit exceptions.

How was this patch tested?

Manual test.

Was this patch authored or co-authored using generative AI tooling?

No.

@pan3793

pan3793 commented Jun 30, 2025

Copy link
Copy Markdown
Member Author

cc @vinodkc (who authored SPARK-35747) @dongjoon-hyun @yaooqinn

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To @pan3793 , given the posted example, this PR may leak a user information more as a new security vulnerability.

Caused by: org.apache.hadoop.hbase.ipc.RemoteWithExtrasException: org.apache.hadoop.hbase.security.AccessDeniedException: Insufficient permissions (user=bdms_admin.mammut/dev@BDMS.COM, scope=hbase:meta, params=[table=hbase:meta,],action=EXEC)

@pan3793

pan3793 commented Jun 30, 2025

Copy link
Copy Markdown
Member Author

@dongjoon-hyun thank you for raising concerns. I would argue that the username/principal is relatively insensitive information in such a context, username/principal is also displayed in the Spark UI / Environment page without redaction, and users would see a similar error message when they access Hive databases/tables or HDFS files without permission.

@dongjoon-hyun

Copy link
Copy Markdown
Member

Got it. It sounds reasonable to me.

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, LGTM (from my side). Thank you always, @pan3793 .

@yaooqinn yaooqinn closed this in e8384d5 Jul 3, 2025
yaooqinn pushed a commit that referenced this pull request Jul 3, 2025
…Hive DelegationTokenProvider hit exception

### What changes were proposed in this pull request?

After SPARK-35747(3.2.0), Spark stops printing full stacktrace when HBase/Hive/Kafka DelegationTokenProvider hit exceptions.

SPARK-35747 actually makes two changes:
1. Remove full stacktrace from logs
2. Guide disabling unused DelegationTokenProvider - `If $serviceName is not used, set spark.security.credentials.$serviceName.enabled to false`

I think 2 is useful, but 1 is incorrect, this PR logically reverts 1 (changes in KafkaDelegationTokenProvider have been reverted in SPARK-47593(4.0.0))

We recently hit an issue related to HBaseDelegationTokenProvider, the printed error message is
```
[WARN] [main] HBaseDelegationTokenProvider#94 - Failed to get token from service hbase due to java.lang.reflect.InvocationTargetException. If hbase is not used, set spark.security.credentials.hbase.enabled to false. Retrying to fetch HBase security token with hbase connection parameter.
```
it makes us think it's related to a classpath issue, but eventually, after we changed the code to print the full stacktrace, we found the root cause is
```
org.apache.hadoop.hbase.security.AccessDeniedException: Insufficient permissions (user=***/******.COM, scope=hbase:meta, params=[table=hbase:meta,],action=EXEC)
```
Full stacktrace: https://gist.github.com/pan3793/46a3f6b956a7982646e1ee75603a1865

### Why are the changes needed?

Improve the diagnosis experience.

### Does this PR introduce _any_ user-facing change?

Yes, the user would see rich error messages when HBase/Hive DelegationTokenProvider hit exceptions.

### How was this patch tested?

Manual test.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #51320 from pan3793/SPARK-52613.

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
(cherry picked from commit e8384d5)
Signed-off-by: Kent Yao <yao@apache.org>
@yaooqinn

yaooqinn commented Jul 3, 2025

Copy link
Copy Markdown
Member

Merged to master and 4.0, thank you @pan3793 @dongjoon-hyun

zifeif2 pushed a commit to zifeif2/spark that referenced this pull request Nov 14, 2025
…Hive DelegationTokenProvider hit exception

### What changes were proposed in this pull request?

After SPARK-35747(3.2.0), Spark stops printing full stacktrace when HBase/Hive/Kafka DelegationTokenProvider hit exceptions.

SPARK-35747 actually makes two changes:
1. Remove full stacktrace from logs
2. Guide disabling unused DelegationTokenProvider - `If $serviceName is not used, set spark.security.credentials.$serviceName.enabled to false`

I think 2 is useful, but 1 is incorrect, this PR logically reverts 1 (changes in KafkaDelegationTokenProvider have been reverted in SPARK-47593(4.0.0))

We recently hit an issue related to HBaseDelegationTokenProvider, the printed error message is
```
[WARN] [main] HBaseDelegationTokenProvider#94 - Failed to get token from service hbase due to java.lang.reflect.InvocationTargetException. If hbase is not used, set spark.security.credentials.hbase.enabled to false. Retrying to fetch HBase security token with hbase connection parameter.
```
it makes us think it's related to a classpath issue, but eventually, after we changed the code to print the full stacktrace, we found the root cause is
```
org.apache.hadoop.hbase.security.AccessDeniedException: Insufficient permissions (user=***/******.COM, scope=hbase:meta, params=[table=hbase:meta,],action=EXEC)
```
Full stacktrace: https://gist.github.com/pan3793/46a3f6b956a7982646e1ee75603a1865

### Why are the changes needed?

Improve the diagnosis experience.

### Does this PR introduce _any_ user-facing change?

Yes, the user would see rich error messages when HBase/Hive DelegationTokenProvider hit exceptions.

### How was this patch tested?

Manual test.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#51320 from pan3793/SPARK-52613.

Authored-by: Cheng Pan <chengpan@apache.org>
Signed-off-by: Kent Yao <yao@apache.org>
(cherry picked from commit eeab1d2)
Signed-off-by: Kent Yao <yao@apache.org>
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.

3 participants