Skip to content

Commit

Permalink
Fix postgres_*prepared_xacts_ plugins.
Browse files Browse the repository at this point in the history
postgres_oldest_prepared_xact_ and postgres_prepared_xacts_ uses the same
"wildcardfilter" ("WHERE database=?") in their "configquery" and their
"basequery".

But those two queries uses two different tables, with different columns
names to refer to the database name ; the "pg_database" table has a "datname"
column, while the "pg_prepared_xacts" view has a "database" column.
So we can't add a "WHERE $something=?" filter as is in both queries.

Let's add a gratuitous JOIN in the "basequery" (joining pg_database, so
we're sure any existing database name will be joined) ; then we can
use a common "WHERE datname=?" filter on both queries.

Those tables columns are still the same since xact statistics where
introduced, in PostgreSQL 8.1, so this plugin's config had always been broken.
http://www.postgresql.org/docs/8.1/static/release-8-1.html
http://www.postgresql.org/docs/8.1/static/view-pg-prepared-xacts.html
http://www.postgresql.org/docs/8.1/static/catalog-pg-database.html
  • Loading branch information
bpineau committed Sep 28, 2012
1 parent 9f1f507 commit b29cf30
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions plugins/node.d/postgres_oldest_prepared_xact_.in
Expand Up @@ -67,8 +67,8 @@ my $pg = Munin::Plugin::Pgsql->new(
vlabel => 'Age (seconds)',
minversion => '8.1',
basequery =>
"SELECT database, COALESCE(max(extract(epoch FROM CURRENT_TIMESTAMP-prepared)),0) FROM pg_prepared_xacts %%FILTER%% GROUP BY database ORDER BY 1",
wildcardfilter => "WHERE database=?",
"SELECT database, COALESCE(max(extract(epoch FROM CURRENT_TIMESTAMP-prepared)),0) FROM pg_prepared_xacts JOIN pg_database ON datname=database %%FILTER%% GROUP BY database ORDER BY 1",
wildcardfilter => "WHERE datname=?",
configquery =>
"SELECT datname,datname FROM pg_database %%FILTER%% ORDER BY 1",
suggestquery => "SELECT 'ALL'",
Expand Down
4 changes: 2 additions & 2 deletions plugins/node.d/postgres_prepared_xacts_.in
Expand Up @@ -67,8 +67,8 @@ my $pg = Munin::Plugin::Pgsql->new(
vlabel => 'Transactions',
minversion => '8.1',
basequery =>
"SELECT database, count(*) FROM pg_prepared_xacts %%FILTER%% GROUP BY database ORDER BY 1",
wildcardfilter => "WHERE database=?",
"SELECT database, count(*) FROM pg_prepared_xacts JOIN pg_database ON datname=database %%FILTER%% GROUP BY database ORDER BY 1",
wildcardfilter => "WHERE datname=?",
configquery =>
"SELECT datname,datname FROM pg_database %%FILTER%% ORDER BY 1",
suggestquery => "SELECT 'ALL'",
Expand Down

0 comments on commit b29cf30

Please sign in to comment.