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

Issue 53: stopping of primary when it becomes isolated #54

Closed

Conversation

frodolooijaard
Copy link

@frodolooijaard frodolooijaard commented Mar 1, 2020

resolves #53
Create two new config keys:

  • minimum_replicating_nodes (default: disabled)
    The minimum number of nodes the master should be replicating with.
    If the number of replicating nodes falls below this mark, then
    too_few_replicating_nodes_command is called if defined.
  • too_few_replicating_nodes_command (default: disabled)
    When the number of replicating nodes on the master falls
    below minimum_replicating_nodes, this command is called.
    Note that it will be called repeatedly as long as this condition continues.

The query that is run on the master node is enhanced to count the number
of records in pg_stat_replication; this is stored in in the field
pg_master_replication_connections.

The too_few_replicating_nodes_command can simply stop the master, or do
more checking first, or whatever. Because the script is called repeatedly,
if you want to stop the master, you should first test whether it is running,
to avoid pg_ctl giving errors.

Create two new config keys:
  * minimum_replicating_nodes (default: disabled)
    The minimum number of nodes the master should be replicating with.
    If the number of replicating nodes falls below this mark, then
    too_few_replicating_nodes_command is called if defined.
  * too_few_replicating_nodes_command (default: disabled)
    When the number of replicating nodes on the master falls
    below minimum_replicating_nodes, this command is called.
    Note that it will be called repeatedly as long as this condition continues.

The query that is run on the master node is enhanced to count the number
of records in pg_stat_replication; this is stored in in the field
pg_master_replication_connections.

The too_few_replicating_nodes_command can simply stop the master, or do
more checking first, or whatever. Because the script is called repeatedly,
if you want to stop the master, you should first test whether it is running,
to avoid pg_ctl giving errors.
Also, too_few_replicating_nodes_command is only called when the master
is actually running.
A primary was not started if there were multiple primaries in the cluster and
it was not considered the main primary.
@frodolooijaard frodolooijaard requested a review from a team as a code owner February 17, 2023 11:37
@frodolooijaard frodolooijaard deleted the stop_isolated_primary branch June 5, 2023 04:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stopping of isolated primary
1 participant