-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29254-Display TxnId associated with the query in show processlis… #6141
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: master
Are you sure you want to change the base?
Conversation
|
@tarak271 , code changes LGTM but I'm not able to see the
Do we need to make changes in org.apache.hadoop.hive.ql.processors.ShowProcessListProcessor#getSchema() |
service/src/java/org/apache/hive/service/cli/operation/ShowProcessListOperation.java
Outdated
Show resolved
Hide resolved
| private final String runtime; // tracks only running portion of the query. | ||
| private final long elapsedTime; | ||
| private final String state; | ||
| private final long txnId; |
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.
I might be wrong. Don't we need to read this variable in ShowProcessListProcessor.java?
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.
Yes, you are correct. Added getter to use in that class
@Aggarwal-Raghav yes, made those changes, please try now |
|
@tarak271, after the changes the TxnID is visible in the |
| executor.submit(() -> { | ||
| try (Connection con = DriverManager.getConnection(miniHS2.getJdbcURL(), user, "bar"); | ||
| Statement stmt = con.createStatement()) { | ||
| stmt.execute("drop database if exists DB_" + Thread.currentThread().threadId() + " cascade"); |
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.
The following is my personal opinion:
- The thread pool reuses its 5 threads to execute the 20 tasks, the same thread ID will be used multiple times. Its doesn't align with the intent of having 20 distinct operations as
DROP DATABASEmight have same threadId. - How 20 iterartions of for loop is decided? Is there any way to make it more deterministic?
- if executor.getActiveCount() is 0 then the Assert statement won't get invoked. The core logic might not be getting tested and test will still pass.
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.
@Aggarwal-Raghav Please find below responses
- The idea is to simulate 10/20 connections/queries which can open transactions. A new txnId will be opened for every query irrespective of the connection or thread
- We can take any number of threads, for now I am keeping it to 10, i.e 10 queries will be run and the txnIds for those queries can be captured using show processlist and cross verify it txnid got opened or not
- Moved assert out of that loop. This loop will keep on executing until all the queries got executed & all the transactions got captured using show processlist. At the end checking if 10 transactions were opened or not for those 10 queries
|





…t command
What changes were proposed in this pull request?
Display TxnId for each query displayed in show processlist query
Why are the changes needed?
To co-relate TxnId and query
Does this PR introduce any user-facing change?
Yes
How was this patch tested?
Created Junit test case as well as Tested in local cluster
0: jdbc:hive2://ip-10-17-78-194.support.fuse.> show processlist; +------------+---------------+-------------------+---------------------------------------+--------------------------+------------------------+----------------------------------------------------+----------+---------+--------------------------+-------------------+---------------+ | User Name | Ip Addr | Execution Engine | Session Id | Session Active Time (s) | Session Idle Time (s) | Query ID | State | Txn ID | Opened Timestamp (s) | Elapsed Time (s) | Runtime (s) | +------------+---------------+-------------------+---------------------------------------+--------------------------+------------------------+----------------------------------------------------+----------+---------+--------------------------+-------------------+---------------+ | hive | 10.17.78.194 | tez | b6a7a9da-a01e-4e4e-b5bd-38c0edd54867 | 119 | 6 | hive_20251017043354_b66fb35a-0e8c-476a-a48c-0805276cfd40 | RUNNING | 610 | 2025-10-17 04:33:54.639 | 9 | Not finished | +------------+---------------+-------------------+---------------------------------------+--------------------------+------------------------+----------------------------------------------------+----------+---------+--------------------------+-------------------+---------------+