Skip to content

Commit c403fc2

Browse files
committed
fix: check execute privilege before calling pg_stat_file in multixact_size
The multixact_size metric checks if pg_stat_file() exists but not whether the monitoring user has EXECUTE permission on it. On managed databases like Supabase, the function exists but is restricted to superusers, causing "permission denied for function pg_stat_file". Add has_function_privilege() check to the can_local CTE so the local_probe_xml branch is skipped when the user lacks permission. https://claude.ai/code/session_01SzJxzZNQjDQphaHyaX3RU7
1 parent 15ccc69 commit c403fc2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

config/pgwatch-prometheus/metrics.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2397,7 +2397,9 @@ metrics:
23972397
exists (select from pg_proc where proname = 'pg_stat_file') as has_pg_stat_file_func
23982398
),
23992399
can_local as (
2400-
select (has_pg_ls_dir_func and has_pg_stat_file_func) as ok from env
2400+
select (has_pg_ls_dir_func and has_pg_stat_file_func
2401+
and has_function_privilege('pg_stat_file(text,boolean)', 'execute')
2402+
) as ok from env
24012403
),
24022404
-- Use query_to_xml to safely execute Aurora-specific multixact query.
24032405
-- Aurora uses aurora_stat_file() function instead of rds_tools.pg_ls_multixactdir().

0 commit comments

Comments
 (0)