From d8c0f087105ac5a271f1813029e36f2e97758ba9 Mon Sep 17 00:00:00 2001 From: Nick Carboni Date: Thu, 1 Feb 2018 18:03:20 -0500 Subject: [PATCH] Dont mess with pglogical from PostgresAdmin 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 --- lib/gems/pending/util/postgres_admin.rb | 32 ------------------------- 1 file changed, 32 deletions(-) diff --git a/lib/gems/pending/util/postgres_admin.rb b/lib/gems/pending/util/postgres_admin.rb index 95501fb15..fa97cb001 100644 --- a/lib/gems/pending/util/postgres_admin.rb +++ b/lib/gems/pending/util/postgres_admin.rb @@ -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 = /^\((?\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 @@ -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])