Skip to content

Commit 23d4de7

Browse files
authored
Add check that identifies any active locks (#166)
1 parent b78ebdc commit 23d4de7

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

internal/flycheck/pg.go

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,28 @@ func CheckPostgreSQL(ctx context.Context, checks *check.CheckSuite) (*check.Chec
4545
return connectionCount(ctx, localConn)
4646
})
4747

48-
if member.Role == flypg.PrimaryRoleName && member.Active {
49-
// Check that provides additional insight into disk capacity and
50-
// how close we are to hitting the readonly threshold.
51-
checks.AddCheck("disk-capacity", func() (string, error) {
52-
return diskCapacityCheck(ctx, node)
48+
if member.Role == flypg.PrimaryRoleName {
49+
// Check to see if any locks are present.
50+
checks.AddCheck("cluster-locks", func() (string, error) {
51+
if flypg.ZombieLockExists() {
52+
return "", fmt.Errorf("`zombie.lock` detected")
53+
}
54+
55+
if flypg.ReadOnlyLockExists() {
56+
return "", fmt.Errorf("`readonly.lock` detected")
57+
}
58+
59+
return "No active locks detected", nil
5360
})
61+
62+
if member.Active {
63+
// Check that provides additional insight into disk capacity and
64+
// how close we are to hitting the readonly threshold.
65+
checks.AddCheck("disk-capacity", func() (string, error) {
66+
return diskCapacityCheck(ctx, node)
67+
})
68+
}
69+
5470
}
5571

5672
return checks, nil

0 commit comments

Comments
 (0)