Skip to content

PMM-11281: lock conflicts monitoring #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/postgres_exporter/postgres_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,14 @@ var builtinMetricMaps = map[string]intermediateMetricMap{
true,
0,
},
"pg_lock_conflicts": {
map[string]ColumnMapping{
"blocking_pid": {LABEL, "PID of blocking session", nil, nil},
"count": {GAUGE, "Number of blocked sessions", nil, nil},
},
true,
0,
},
"pg_stat_replication": {
map[string]ColumnMapping{
"procpid": {DISCARD, "Process ID of a WAL sender process", nil, semver.MustParseRange("<9.2.0")},
Expand Down
14 changes: 13 additions & 1 deletion cmd/postgres_exporter/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ var queryOverrides = map[string][]OverrideQuery{
ON tmp.mode=tmp2.mode and pg_database.oid = tmp2.database ORDER BY 1`,
},
},

"pg_lock_conflicts": {
{
semver.MustParseRange(">0.0.0"),
`SELECT blockinga.pid AS blocking_pid, count(*) as count
FROM pg_catalog.pg_locks blockedl
JOIN pg_stat_activity blockeda ON blockedl.pid = blockeda.pid
JOIN pg_catalog.pg_locks blockingl ON(blockingl.transactionid=blockedl.transactionid
AND blockedl.pid != blockingl.pid)
JOIN pg_stat_activity blockinga ON blockingl.pid = blockinga.pid
WHERE NOT blockedl.granted
group by blocking_pid`,
},
},
"pg_stat_replication": {
{
semver.MustParseRange(">=10.0.0"),
Expand Down