Skip to content

Commit

Permalink
Dont mess with pglogical from PostgresAdmin
Browse files Browse the repository at this point in the history
We will handle this in the main app rake task before we even get
to this class to do the restore.

This will be cleaner as we can use all the tooling we have built
up around the extension there rather than shelling out to psql
from here

https://bugzilla.redhat.com/show_bug.cgi?id=1540686
  • Loading branch information
carbonin committed Feb 1, 2018
1 parent cd8fcb9 commit d8c0f08
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions lib/gems/pending/util/postgres_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,37 +124,6 @@ def self.restore_pg_basebackup(file)
file
end

def self.unload_pglogical_extension(opts)
runcmd("psql", opts, :command => <<-SQL)
SELECT
drop_subscription
FROM
pglogical.subscription subs,
LATERAL pglogical.drop_subscription(subs.sub_name)
SQL

runcmd("psql", opts, :command => <<-SQL)
DROP EXTENSION pglogical CASCADE
SQL

# Wait for pglogical manager connection to quiesce. Bail after 5 minutes
60.times do
output = runcmd("psql", opts, :command => <<-SQL)
SELECT application_name
FROM pg_stat_activity
WHERE application_name LIKE 'pglogical manager%'
SQL
match = /^\((?<count>\d+) row/.match(output)
count = match ? match[:count].to_i : 0
break if count.zero?

$log.info("MIQ(#{name}.#{__method__}) Waiting on #{count} pglogical connections to close...")
sleep 5
end
rescue AwesomeSpawn::CommandResultError
$log.info("MIQ(#{name}.#{__method__}) Ignoring failure to remove pglogical before restore ...")
end

def self.backup_pg_compress(opts)
opts = opts.dup

Expand All @@ -180,7 +149,6 @@ def self.recreate_db(opts)
end

def self.restore_pg_dump(opts)
unload_pglogical_extension(opts)
recreate_db(opts)

runcmd("pg_restore", opts, :verbose => nil, :exit_on_error => nil, nil => opts[:local_file])
Expand Down

0 comments on commit d8c0f08

Please sign in to comment.