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

Make replication excludes specific by region #12592

Merged

Conversation

carbonin
Copy link
Member

This PR will move the replication exclude settings out of the global settings and instead read and write directly to the pglogical configuration in the database. This change will allow us to decouple the replication settings from the server record and have them be consistent across all the servers which talk to the same database.

Previously, each server could set the exclude tables independently which could cause workers on different servers to add and remove tables rapidly as they updated their configuration.

A separate file will be kept to determine the default replication excludes when a node is created.

This also adds an interface for the UI to display the current excludes and refresh them using the queue.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821

@Fryguy @gtanzillo please review

/cc @lgalis

@carbonin
Copy link
Member Author

Leaving this as WIP until I can figure out if we need a migration for handling upgrades.

The issue is that users already have replication excludes set in the settings and we would want to continue using those after the upgrade (especially if they are upgrading from rubyrep to pglogical).

@carbonin
Copy link
Member Author

@Fryguy I think the easier way to go regarding upgrades is to just reset the excludes to the default.

If we try to do something else we run into logical issues around what happens if different servers have different excludes at the time of upgrade. Because we only use them when pglogical is enabled we could have files with different contents on different servers and run into exactly the issue we are trying to solve.

If users are already using pglogical replication this will be fine and will pick up their configured excludes from the pglogical tables.

The only people this will effect are the ones going from rubyrep to pglogical that want to keep their old set of exclude tables, but we recommend that they use the default anyway.

@carbonin
Copy link
Member Author

Another side-effect of this change is that excludes don't persist if you go from having pglogical configured (remote replication type) to not configured and back again.

This is just because we are keeping track of the excludes by reading pglogical's tables. I don't think that is too surprising a behavior, but it is a change from the previous way we did it.

This will allow us to move away from storing this database centric
setting as related to the server.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821
This also exposes a new method, `#active_excludes`, to retrieve
the current excludes being used by pglogical. This will pull
the list of tables directly from the pglogical tables in the
database rather than using an intermediate list of settings
related to the server.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821
We can't use the instance methods with the queue because this is
not an ActiveRecord object.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821
This is no longer needed because the exclude tables are not stored
in the global Settings anymore.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821
…ances

This means that `MiqPglogical.new.refresh_excludes` will not change
the excluded tables back to the default, but will leave them as
they currently are.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821
@carbonin carbonin force-pushed the make_replication_excludes_specific_by_region branch from 4f86504 to aefb554 Compare November 11, 2016 20:54
@carbonin carbonin changed the title [WIP] Make replication excludes specific by region Make replication excludes specific by region Nov 11, 2016
@carbonin carbonin removed the wip label Nov 11, 2016
@Fryguy
Copy link
Member

Fryguy commented Nov 12, 2016

The only people this will effect are the ones going from rubyrep to pglogical that want to keep their old set of exclude tables, but we recommend that they use the default anyway.

Totally forgot about that, and with that I agree with everything else.

:value => %w(schema_migrations))
server_two.settings_changes
.create!(:key => described_class::EXCLUDES_KEY,
:value => %w(ar_internal_metadata))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor but you might want one more test of some other change to ensure it's not being killed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just set resource_type and resource_id to any arbitrary value instead

describe RemoveReplicationExcludesFromSettings do
let(:settings_change_stub) { migration_stub(:SettingsChange) }
let(:server_one) { FactoryGirl.create(:miq_server) }
let(:server_two) { FactoryGirl.create(:miq_server) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using factories in migration specs as they load the real models.

@Fryguy
Copy link
Member

Fryguy commented Nov 12, 2016

A couple of minor comments with the specs, but otherwise this looks good!

Because we have removed the excludes from the settings.yml file
we should remove the changes made in the database.

This will leave current installations of pglogical in the same state
they were in (we will read the excludes from the pglogical tables),
but will reset new installations created when moving from rubyrep
to pglogical.

https://bugzilla.redhat.com/show_bug.cgi?id=1389821
@carbonin carbonin force-pushed the make_replication_excludes_specific_by_region branch from aefb554 to 0e79109 Compare November 14, 2016 19:47
@miq-bot
Copy link
Member

miq-bot commented Nov 14, 2016

Checked commits carbonin/manageiq@f50c798~...0e79109 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
5 files checked, 1 offense detected

lib/miq_pglogical.rb

@Fryguy Fryguy merged commit bb2da1a into ManageIQ:master Nov 14, 2016
@Fryguy
Copy link
Member

Fryguy commented Nov 14, 2016

@chessbyte I just realized this has a SQL migration, so it can't be backported directly. @carbonin Can you do a separate backport PR without the SQL migration?

@carbonin
Copy link
Member Author

Euwe backport PR #12625

@chessbyte
Copy link
Member

Backported to Euwe via #12625

@chessbyte chessbyte modified the milestones: Sprint 50 Ending Dec 5, 2016, Sprint 49 Ending Nov 14, 2016 Nov 17, 2016
@carbonin carbonin deleted the make_replication_excludes_specific_by_region branch March 7, 2017 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants