-
Notifications
You must be signed in to change notification settings - Fork 2k
[Fix][Connector-V2] Fix hive client thread unsafe #9282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes a thread safety issue with the Hive client used by the Hive connector by refactoring resource management and removing the singleton pattern. The changes include:
- Replacing a singleton instance with a try-with-resources block in HiveTableUtils.java.
- Refactoring HiveMetaStoreProxy to implement Closeable and Serializable with explicit client initialization.
- Updating HiveSinkAggregatedCommitter to use the new HiveMetaStoreProxy instance and manage its lifecycle appropriately.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveTableUtils.java | Refactored to use try-with-resources for HiveMetaStoreProxy, helping ensure proper resource cleanup. |
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java | Removed singleton pattern, added explicit client initialization, and updated resource closing logic. |
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/commit/HiveSinkAggregatedCommitter.java | Integrated usage of the new HiveMetaStoreProxy instance and adjusted resource management. |
Comments suppressed due to low confidence (1)
seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreProxy.java:183
- After closing hiveClient in the close() method, consider setting hiveClient to null to prevent accidental reuse of a closed client in subsequent calls.
if (Objects.nonNull(hiveClient)) { hiveClient.close(); }
return new HiveMetaStoreClient(hiveConf); | ||
}); | ||
return; | ||
private HiveMetaStoreClient hiveClient; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private HiveMetaStoreClient hiveClient; | |
private transient HiveMetaStoreClient hiveClient; |
Purpose of this pull request
Does this PR introduce any user-facing change?
How was this patch tested?
Check list
New License Guide
release-note
.