Re: bug reapper: Empty query_id in pg_stat_activity - Mailing list pgsql-bugs

From Greg Sabino Mullane
Subject Re: bug reapper: Empty query_id in pg_stat_activity
Date
Msg-id CAKAnmmJCuif76-RF5BLfmKrLS_8FQcivad2UbT9S-P3kGFyUmQ@mail.gmail.com
Whole thread Raw
In response to Re: bug reapper: Empty query_id in pg_stat_activity  (Srinath Reddy Sadipiralla <srinath2133@gmail.com>)
Responses Re: bug reapper: Empty query_id in pg_stat_activity
List pgsql-bugs
If I am reading the code in utils/activity/backend_status.c correctly, I not only see where it is happening (pgstat_report_activity), but why it is happening as well. There is definitely a race condition as we know what the query is before we have a chance to parse it and generate a query identifier for it. I'm not sure of the solution - we cannot exclude null query identifiers from the output, or callers will see the backend disappear briefly! We cannot avoid setting it to 0, as then we could have a query != query_id. We could store the query string somewhere and only reveal it once we have the identifier, but that's also tricky because we risk not setting it (and because we also set other things at the same time as the name, which would then be further disconnected). But maybe its the best option? I do agree this is a bug (and like Srinath, I can duplicate easily).

Anyway, my pre-caffeine two cents.

Cheers,
Greg

--
Enterprise Postgres Software Products & Tech Support

pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #19034: Recursive function with sql_body can replace an existing function but can not be created on it's own
Next
From: Srinath Reddy Sadipiralla
Date:
Subject: Re: bug reapper: Empty query_id in pg_stat_activity