Skip to content

Commit 2726997

Browse files
Robert Marshallbalasankarc
andcommitted
Merge branch '8166-fix-pgb-notify' into 'master'
Fix finding paused databases from pgbouncer show databases command Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8166 See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7163 Merged-by: Robert Marshall <[email protected]> Approved-by: Robert Marshall <[email protected]> Co-authored-by: Balasankar "Balu" C <[email protected]>
2 parents 7327497 + 8626200 commit 2726997

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

files/gitlab-ctl-commands-ee/lib/pgbouncer.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ def database_paused?
133133

134134
databases = show_databases
135135

136-
# In `show databases` output, column 10 gives paused status of database
137-
# (1 for paused and 0 for unpaused)
138-
paused_status = databases.lines.find { |x| x.match(/#{@database}/) }.split('|')[10].strip
136+
# Find the headings of the output from `SHOW DATABASES` to find out the location of the `paused` column
137+
headings = databases.lines.first.split("|").map(&:strip)
138+
paused_position = headings.index('paused')
139139

140+
# Find the paused value of the specified database
141+
paused_status = databases.lines.find { |x| x.match(/#{@database}/) }.split('|')[paused_position].strip
142+
143+
# 1 for paused and 0 for unpaused
140144
paused_status == "1"
141145
end
142146

0 commit comments

Comments
 (0)