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
query_id in pg_stat_activity is NULL when connecting from JDBC, but not from psql #3166
Comments
I just tested your code and |
I see that you get the "correct" row at row 3 (is that a JDBC Connection or "something else") Below is my full output (only 2 rows)
|
If it's a config issue... here are my config for version
I could not attach my shell script here (shell scripts wasn't supported) that installs a new Postgres 16.x instance on a "clean" CentOS-9 or RHEL 9 VM |
There should be no reason that query_id can't be read by JDBC. It does nothing different. |
I totally agree with you! Executing the above SQL from
Executing the same SQL from JDBC yields this result (query_id is NULL)
I simplified my Java repro code in the following way, so if you can try that simplification on your server and post the output
|
will do |
Ok, well that is beyond bizarre, will figure this out. |
Ok, so here's what is happening. The driver uses Extended Protocol so normally it does
And apparently query_id is not calculated for that. Add Dave |
I would treat simple query mode as a workaround only, and I would refrain from recommending "simple" by default.
Do you mean backend does not produce query_id for extended queries? It sounds strange. |
I can verify that If I should go ahead and change the jdbc URL for all involved client (appservers/and-various-tools), which is doable but not really the preferred way I would still question why And I agree with @vlsi that it's strange that |
That is correct. Known issue. https://postgrespro.com/list/thread-id/2652444 Dave |
To avoid SQL injection
No
see https://postgrespro.com/list/thread-id/2652444
|
So a pretty good reason to not go to
But a bug/feature-request for the issue can be raised??? |
You can add a request onto the email thread I referenced, but I wouldn't get my hopes up. |
Technically speaking, |
Describe the issue
query_id
inpg_stat_activity
is NULL when connecting from JDBC, but not frompsql
Driver Version?
42.7.2 (postgresql-42.7.2.jar)
Java Version?
21.0.1 (or any)
OS Version?
Windows 11 (I guess any here as well)
PostgreSQL Version?
16.2 on CentOS 9
To Reproduce
Expected behaviour
query_id
should not be NULLLogs
nothing in the logs
Why I need this
In my monitoring tool (https://github.com/goranschwarz/DbxTune)
I get query_plan information from the errorlog using
auto_explain
and then cache that plan in memory.If a new query comes with the same
query_id
I can now show the query plan in "Active Statements", withpev2
or som other Query Plan ViewerNote: It would be even better if I could retrive the
query plan
at runtime...Meaning:
select get_query_plan_for_current_running_pid(###)
, but that isn't around, so have to come up with something...But now I trapped over that that all JDBC connections just do not show the
query_id
... bummer :(Reproducable code
The text was updated successfully, but these errors were encountered: