Skip to content

Commit 8626200

Browse files
balasankarcRobert Marshall
authored andcommitted
Fix finding paused databases from pgbouncer show databases command
- Dynamically locates the correct index for the paused database field in output to avoid problems where upstream changes to the output would then cause the high available failover mechanisms to fail when the primary database node goes down. Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8166 Changelog: fixed Signed-off-by: Balasankar "Balu" C <[email protected]>
1 parent a04ab5c commit 8626200

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)