Repository navigation
Commit 3d9e62a
authored
fix(postgres): filter background processes in postgres-list-active-queries (#3885)
## Description
This PR updates the `postgres-list-active-queries` tool statement to
filter out internal PostgreSQL/AlloyDB system background processes by
adding `AND backend_type = 'client backend'` to the `pg_stat_activity`
query.
## Context
* Following the upgrade of our shared AlloyDB test instance from PG 15
to PG 17
([screenshot](https://screenshot-v2.corp.google.com/3vi4uot403tmg)),
AlloyDB's continuous replication streaming worker remained continuously
active in `pg_stat_activity`.
* Because `postgres-list-active-queries` queries `pg_stat_activity WHERE
state = 'active'` without filtering for client connections, this
internal background worker was returned alongside user queries, causing
`TestAlloyDBPgToolEndpoints/invoke_list_active_queries_when_the_system_is_idle`
to fail on the idle check.
* When users run `postgres-list-active-queries`, they expect to see
queries initiated by client applications/users, not internal database
infrastructure workers.
* Adding `backend_type = 'client backend'` is the standard PostgreSQL
mechanism (supported across PG 10+) to isolate user/client sessions from
engine background processes.
## Changes
* Added `AND backend_type = 'client backend'` in
`internal/tools/postgres/postgreslistactivequeries/postgreslistactivequeries.go`.1 parent 81e5b01 commit 3d9e62a
1 file changed
Lines changed: 1 addition & 0 deletions
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
0 commit comments