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

From Srinath Reddy Sadipiralla
Subject Re: bug reapper: Empty query_id in pg_stat_activity
Date
Msg-id CAFC+b6qwZ9zkWjNy+km7xkF2VvM+T=ye5+PCeCmpjagtFLPX0g@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>)
List pgsql-bugs


On Thu, Aug 28, 2025 at 5:55 PM Srinath Reddy Sadipiralla <srinath2133@gmail.com> wrote: 
sorry for half cooked analysis ,the reason is pgstat_report_query_id() zeroes st_query_id before the new one is computed in exec_simple_query(). A concurrent reader of pg_stat_activity during that narrow timing gap observes 0 (displayed as NULL). The fix I tried is to retain the previous query_id (prev_st_query_id) and return it when st_query_id is still 0 but query_id computation is enabled, thoughts?

I was able to reproduce this on 15.14 and master also , I think we have to backpatch the fix.

--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

pgsql-bugs by date:

Previous
From: Srinath Reddy Sadipiralla
Date:
Subject: Re: bug reapper: Empty query_id in pg_stat_activity
Next
From: Greg Sabino Mullane
Date:
Subject: Re: bug reapper: Empty query_id in pg_stat_activity