Skip to content

[SPARK-47931][SQL] Remove unused and leaked threadlocal/session sessionHive#46153

Closed
yaooqinn wants to merge 1 commit intoapache:masterfrom
yaooqinn:SPARK-47931
Closed

[SPARK-47931][SQL] Remove unused and leaked threadlocal/session sessionHive#46153
yaooqinn wants to merge 1 commit intoapache:masterfrom
yaooqinn:SPARK-47931

Conversation

@yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Apr 22, 2024

What changes were proposed in this pull request?

This sessionHive is never used and properly closed

Why are the changes needed?

A thread local hive instance like sessionHive shall be closed properly via 'Hive.closeCurrent'; Otherwise, There will be HMS connection leaks. Here we just remove it as we never use it for HMS connectivities.

Does this PR introduce any user-facing change?

no

How was this patch tested?

pass compilation

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

no

@github-actions github-actions bot added the SQL label Apr 22, 2024
@yaooqinn
Copy link
Member Author

cc @dongjoon-hyun @cloud-fan thanks

if (sessionHive != null) {
Hive.set(sessionHive);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

I thought HiveSessionImplwithUGI need to override this because of the impersonation. Do you mean HiveSessionImpl's implementation is enough to handle UGI use case?

Copy link
Member Author

Choose a reason for hiding this comment

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

UGI is set by setSessionUGI?

super.acquire(userAccess);
// if we have a metastore connection with impersonation, then set it first
if (sessionHive != null) {
Hive.set(sessionHive);
Copy link
Contributor

Choose a reason for hiding this comment

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

does it have side effects?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removing or existing?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hive.set(sessionHive) this code looks like having side effects. Is it really safe to remove it?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the Hive repo, it implements this logic in its superclass HiveSessionImpl. In the Spark repo, we have this in HiveSessionImplwithUGI only but we mostly use HiveSessionImpl w/o this.

The Hive metadata operations rely upon this, but on the spark side, the metadata operations have been overridden with catalog APIs.

@dongjoon-hyun
Copy link
Member

cc @sunchao, @LuciferYang , @pan3793 , too

@LuciferYang
Copy link
Contributor

also cc @wangyum FYI

@yaooqinn yaooqinn closed this in d1298e7 Apr 23, 2024
@yaooqinn
Copy link
Member Author

Thank you @LuciferYang and all. Merged to master.

@yaooqinn yaooqinn deleted the SPARK-47931 branch April 23, 2024 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants