Skip to content

Commit 008901a

Browse files
17376 FIX Empty postgres_bloat section under windows
This werk could be relevant for you in case you monitor multiple postgres databases on a windows host. If the corresponding `postgres_bloat` section is empty: ``` <<<postgres_bloat:sep(59)>>> [[[data]]] [databases_start] postgres another_db yet_another_db [databases_end] <<<win_netstat:cached(12345676,300)>>> ``` Under windows, the bloat query will now be executed _per_ database in order to avoid that issue. Change-Id: Icedec27b3e5c40135adc233d3e9606541aa3796d JIRA-Ref: SUP-23843
1 parent 972fcae commit 008901a

2 files changed

Lines changed: 42 additions & 5 deletions

File tree

.werks/17376.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[//]: # (werk v2)
2+
# Empty postgres_bloat section under windows
3+
4+
key | value
5+
---------- | ---
6+
date | 2025-07-28T13:32:30+00:00
7+
version | 2.3.0p36
8+
class | fix
9+
edition | cre
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
This werk could be relevant for you in case you monitor multiple postgres databases on a windows host.
15+
If the corresponding `postgres_bloat` section is empty:
16+
```
17+
<<<postgres_bloat:sep(59)>>>
18+
[[[data]]]
19+
[databases_start]
20+
postgres
21+
another_db
22+
yet_another_db
23+
[databases_end]
24+
25+
<<<win_netstat:cached(12345676,300)>>>
26+
```
27+
28+
Under windows, the bloat query will now be executed _per_ database in order to avoid that issue.

agents/plugins/mk_postgres.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -786,13 +786,22 @@ def get_bloat(self, databases, numeric_version):
786786

787787
query = "\\pset footer off \\\\"
788788

789+
response = ""
789790
cur_rows_only = False
791+
# On windows, we saw issues when more than one database was queried at once.
792+
# See SUP-23843
793+
# We therefore execute the query per database and accumulate the results.
790794
for idx, database in enumerate(databases):
791-
query = "%s \\c %s \\\\ %s" % (query, database, bloat_query)
792-
if idx == 0:
793-
query = "%s \\pset tuples_only on" % query
794-
795-
return self.run_sql_as_db_user(query, mixed_cmd=True, rows_only=cur_rows_only)
795+
current_query = "%s \\c %s \\\\ %s" % (query, database, bloat_query)
796+
if idx != 0:
797+
# Switch off the header for all but the first database: this is now needed as we
798+
# execute psql _per_ database but want to get the same format as before.
799+
current_query = "\\pset tuples_only on %s" % current_query
800+
response += "\n"
801+
response += self.run_sql_as_db_user(
802+
current_query, mixed_cmd=True, rows_only=cur_rows_only
803+
)
804+
return response
796805

797806

798807
class PostgresLinux(PostgresBase):

0 commit comments

Comments
 (0)