diff --git a/cspell-dictionary.txt b/cspell-dictionary.txt index d36b6d42db..52110cd1a6 100644 --- a/cspell-dictionary.txt +++ b/cspell-dictionary.txt @@ -412,6 +412,7 @@ urijs uxxxxxxxxx vcpu VERSINFO +walsender webfactory withfig wrapline diff --git a/src/commands/pg/long-running-queries.ts b/src/commands/pg/long-running-queries.ts index 7f4e01ed4e..477090e07f 100644 --- a/src/commands/pg/long-running-queries.ts +++ b/src/commands/pg/long-running-queries.ts @@ -18,6 +18,11 @@ WHERE pg_stat_activity.query <> ''::text AND state <> 'idle' AND now() - pg_stat_activity.query_start > interval '5 minutes' + AND backend_type <> 'walsender' + AND NOT ( + usename = 'postgres' + AND query LIKE '%pg_backup_start%' + ) ORDER BY now() - pg_stat_activity.query_start DESC; `.trim() diff --git a/test/unit/commands/pg/long-running-queries.unit.test.ts b/test/unit/commands/pg/long-running-queries.unit.test.ts index 8247878fc9..92fe16998f 100644 --- a/test/unit/commands/pg/long-running-queries.unit.test.ts +++ b/test/unit/commands/pg/long-running-queries.unit.test.ts @@ -45,6 +45,11 @@ WHERE pg_stat_activity.query <> ''::text AND state <> 'idle' AND now() - pg_stat_activity.query_start > interval '5 minutes' + AND backend_type <> 'walsender' + AND NOT ( + usename = 'postgres' + AND query LIKE '%pg_backup_start%' + ) ORDER BY now() - pg_stat_activity.query_start DESC;` @@ -58,6 +63,17 @@ ORDER BY expect(query).to.contain("state <> 'idle'") expect(query).to.contain("interval '5 minutes'") }) + + it('excludes the internal physical backup query from results', function () { + const query = generateLongRunningQueriesQuery() + expect(query).to.contain("usename = 'postgres'") + expect(query).to.contain("query LIKE '%pg_backup_start%'") + }) + + it('excludes walsender backends from results', function () { + const query = generateLongRunningQueriesQuery() + expect(query).to.contain("backend_type <> 'walsender'") + }) }) describe('command behavior', function () {