Skip to content

Commit

Permalink
fix: added pgpro_stats temporary dirty hack
Browse files Browse the repository at this point in the history
  • Loading branch information
cuprumtan committed Sep 5, 2022
1 parent fc2c875 commit 17f123f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions mamonsu/plugins/pgsql/statements.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ def run(self, zbx):
columns = [x[1] for x in all_items]
elif Pooler.server_version_greater("13"):
self.Items[5][1] = self.Items[5][1].format("total_exec_time+total_plan_time")
if not Pooler.is_pgpro() or not Pooler.is_pgpro_ee():
all_items += self.Items_pg_13
all_items += self.Items_pg_13
columns = [x[1] for x in all_items]
else:
self.Items[5][1] = self.Items[5][1].format("total_time")
Expand Down
8 changes: 4 additions & 4 deletions mamonsu/tools/bootstrap/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
json_data.value::int AS count
FROM (SELECT key, value AS locktuple
FROM jsonb_each((SELECT wait_stats
FROM ' || extension_schema || '.pgpro_stats_totals
FROM ' || extension_schema || '.pgpro_stats_totals()
WHERE object_type = ''cluster''))) setoflocks,
jsonb_each(setoflocks.locktuple) AS json_data)
SELECT
Expand Down Expand Up @@ -321,7 +321,7 @@
json_data.value::int AS count
FROM (SELECT key, value AS locktuple
FROM jsonb_each((SELECT wait_stats
FROM ' || extension_schema || '.pgpro_stats_totals
FROM ' || extension_schema || '.pgpro_stats_totals()
WHERE object_type = ''cluster''))) setoflocks,
jsonb_each(setoflocks.locktuple) AS json_data)
SELECT
Expand All @@ -341,7 +341,7 @@
json_data.value::int AS count
FROM (SELECT key, value AS locktuple
FROM jsonb_each((SELECT wait_stats
FROM ' || extension_schema || '.pgpro_stats_totals
FROM ' || extension_schema || '.pgpro_stats_totals()
WHERE object_type = ''cluster''))) setoflocks,
jsonb_each(setoflocks.locktuple) AS json_data
WHERE setoflocks.key IN (''Lock'', ''LWLock'', ''LWLockTranche'', ''LWLockNamed''))
Expand Down Expand Up @@ -415,7 +415,7 @@
CREATE OR REPLACE FUNCTION mamonsu.statements_pro()
RETURNS TABLE({columns}) AS $$
SELECT {metrics}
FROM ' || extension_schema || '.pgpro_stats_totals
FROM ' || extension_schema || '.pgpro_stats_totals()
WHERE object_type = ''cluster'';
$$ LANGUAGE SQL SECURITY DEFINER;';
ELSE
Expand Down
13 changes: 7 additions & 6 deletions mamonsu/tools/bootstrap/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,13 @@ def run_deploy():
if Pooler.is_pgpro() or Pooler.is_pgpro_ee():
bootstrap_extension_queries = fill_query_params(CreateWaitSamplingFunctionsSQL)
Pooler.query(bootstrap_extension_queries)
statements_items = [x[1] for x in Statements.Items]
statements_items[5] = statements_items[5].format("total_exec_time+total_plan_time")
statements_columns = [x[0][x[0].find("[")+1:x[0].find("]")] for x in Statements.Items]
bootstrap_extension_queries = CreateStatementsFunctionsSQL.format(
columns=" bigint, ".join(statements_columns) + " bigint", metrics=(", ".join(statements_items)))
Pooler.query(bootstrap_extension_queries)
if Pooler.server_version_greater("12"):
statements_items = [x[1] for x in Statements.Items] + ([x[1] for x in Statements.Items_pg_13] if Pooler.server_version_greater("13") else [])
statements_items[5] = statements_items[5].format("total_exec_time+total_plan_time")
statements_columns = [x[0][x[0].find("[")+1:x[0].find("]")] for x in Statements.Items] + ([x[0][x[0].find("[")+1:x[0].find("]")] for x in Statements.Items_pg_13] if Pooler.server_version_greater("13") else [])
bootstrap_extension_queries = CreateStatementsFunctionsSQL.format(
columns=" bigint, ".join(statements_columns) + " bigint", metrics=(", ".join(statements_items)))
Pooler.query(bootstrap_extension_queries)
except Exception as e:
sys.stderr.write(
"Bootstrap failed to create auxiliary extensions and functions.\n"
Expand Down

0 comments on commit 17f123f

Please sign in to comment.