Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push PostgresAdmin.disable_replication into pg-logical_replication #162

Open
NickLaMuro opened this issue May 17, 2021 · 1 comment
Open

Comments

@NickLaMuro
Copy link
Member

It was mentioned in a code review regarding PostgresAdmin that the .disable_replication method might make sense being moved into the pg-logical_replication gem. This issue is intended to discuss that topic.

The method in question (not committed to the project at the time of writing) is the following:

private_class_method def self.disable_replication(dbname)
  require 'pg/logical_replication'

  with_pg_connection do |conn|
    pglogical = PG::LogicalReplication::Client.new(conn)

    if pglogical.subscriber?
      pglogical.subcriptions(dbname).each do |subscriber|
        sub_id = subscriber["subscription_name"]
        begin
          pglogical.drop_subscription(sub_id, true)
        rescue PG::InternalError => e
          raise unless e.message.include?("could not connect to publisher")
          raise unless e.message.match?(/replication slot .* does not exist/)

          pglogical.disable_subscription(sub_id).check
          pglogical.alter_subscription_options(sub_id, "slot_name" => "NONE")
          pglogical.drop_subscription(sub_id, true)
        end
      end
    elsif pglogical.publishes?('miq')
      pglogical.drop_publication('miq')
    end
  end
end

I think some changes would be necessary to make it more generic, but this is the method in question.

@Fryguy Fryguy removed their assignment May 21, 2021
@Fryguy Fryguy changed the title Discussion: Push PostgresAdmin.disable_replication into pg-logical_replication Push PostgresAdmin.disable_replication into pg-logical_replication Jun 2, 2021
@miq-bot miq-bot added the stale label Feb 27, 2023
@miq-bot
Copy link
Member

miq-bot commented Feb 27, 2023

This issue has been automatically marked as stale because it has not been updated for at least 3 months.

If you can still reproduce this issue on the current release or on master, please reply with all of the information you have about it in order to keep the issue open.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

@Fryguy Fryguy removed the stale label Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants