Skip to content

Commit

Permalink
[FIXUP] fix .connection_count
Browse files Browse the repository at this point in the history
  • Loading branch information
NickLaMuro committed Apr 14, 2021
1 parent 0937582 commit c02d242
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/manageiq/appliance_console/postgres_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ class << self

disable_replication(dbname)

if connection_count(backup_type) > 1
message = "Database restore failed. #{connection_count - 1} connections remain to the database."
conn_count = connection_count(backup_type, dbname)
if conn_count > 1
message = "Database restore failed. #{conn_count - 1} connections remain to the database."
ManageIQ::ApplianceConsole.logger.error(message)
raise message
end
Expand Down Expand Up @@ -389,12 +390,12 @@ class << self

with_pg_connection do |conn|
query = "SELECT COUNT(pid) FROM pg_stat_activity"
query << " WHERE backend_type = 'client backend'" if backend_type == :basebackup
query << " WHERE datname = '#{dbname}'" if backend_type == :pgdump
query << " WHERE backend_type = 'client backend'" if backup_type == :basebackup
query << " WHERE datname = '#{dbname}'" if backup_type == :pgdump
result = conn.exec()
end

result = conn.result[0]["count"]
result = conn.result[0]["count"].to_i
end

private_class_method def self.validate_backup_file_type file
Expand Down

0 comments on commit c02d242

Please sign in to comment.