Expand assertion check for query ID reporting in executor
authorMichael Paquier <michael@paquier.xyz>
Mon, 30 Sep 2024 23:56:21 +0000 (08:56 +0900)
committerMichael Paquier <michael@paquier.xyz>
Mon, 30 Sep 2024 23:56:21 +0000 (08:56 +0900)
commit5deb56387e3a1d08e1e62bed031258db267a0ab5
tree9b69323da51cb561dadaf1f2b16b1c0996287717
parent102de3be73345a8de443355e055c10762b08cc4c
Expand assertion check for query ID reporting in executor

As formulated, the assertion added in the executor by 24f520594809 to
check that a query ID is set had two problems:
- track_activities may be disabled while compute_query_id is enabled,
causing the query ID to not be reported to pg_stat_activity.
- debug_query_string may not be set in some context.  The only path
where this would matter is visibly autovacuum, should parallel workers
be enabled there at some point.  This is not the case currently.

There was no test showing the interactions between the query ID and
track_activities, so let's add one based on a scan of pg_stat_activity.
This assertion is still an experimentation at this stage, but let's see
if this shows more paths where query IDs are not properly set while they
should.

Discussion: https://postgr.es/m/Zvn5616oYXmpXyHI@paquier.xyz
src/backend/executor/execMain.c
src/test/regress/expected/guc.out
src/test/regress/sql/guc.sql