-
Notifications
You must be signed in to change notification settings - Fork 53
Add in-core attach_node/detach_node alongside SQL add_node/remove_node #545
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
Open
ibrarahmad
wants to merge
1
commit into
main
Choose a base branch
from
zodan-in-core-node
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,66 @@ | ||
| # Modifying a Cluster with Zodan | ||
|
|
||
| Zodan provides tools to add or remove a node with zero downtime. The | ||
| scripts are located in the | ||
| [samples/Z0DAN](https://github.com/pgEdge/spock/tree/main/samples/Z0DAN) | ||
| directory of the [Spock GitHub](https://github.com/pgEdge/spock) repository. | ||
| Zodan (Zero Downtime Add/Remove Node) adds or removes a node with zero | ||
| downtime for the existing nodes. During node addition it manages creation of | ||
| the new node, subscription management (both to and from the node), replication | ||
| slot creation, data synchronization, replication slot advancement, and final | ||
| activation of subscriptions. During node removal it drops the node's | ||
| subscriptions, replication sets, slots, and origins in the correct order, | ||
| without deleting any Postgres artifacts (the database, data directory, log | ||
| files, and so on). | ||
|
|
||
| Spock offers two ways to run this workflow. Both perform the same steps and | ||
| you can pick whichever fits your environment: | ||
|
|
||
| - **In-core procedures (recommended).** `spock.attach_node` and | ||
| `spock.detach_node` are built into the Spock extension. A single | ||
| `CREATE EXTENSION spock` makes them available: there is no script to load | ||
| and no `dblink` dependency. All orchestration runs inside Spock and reaches | ||
| the other nodes over libpq. | ||
|
|
||
| - **SQL scripts.** `spock.add_node` and `spock.remove_node` are loaded from | ||
| the SQL scripts in the | ||
| [samples/Z0DAN](https://github.com/pgEdge/spock/tree/main/samples/Z0DAN) | ||
| directory and reach the other nodes through the `dblink` extension. This | ||
| method is useful where you prefer to keep the orchestration in a script you | ||
| can read and modify. | ||
|
|
||
| During node addition, Zodan seamlessly manages creation of the new node, | ||
| subscription management (both to and from the node), replication slot | ||
| creation, data synchronization, replication slot advancement, and final | ||
| activation of subscriptions. | ||
| !!! note | ||
|
|
||
| During node removal, Zodan simplifies removing fully-functional or failed | ||
| nodes from a cluster. When you remove a node from a cluster, the removal | ||
| does not delete Postgres artifacts (the database, data directory, log | ||
| files, etc.). | ||
| Whichever method you use, the add procedure (`attach_node` or `add_node`) | ||
| must be run on the new node being added, and the remove procedure | ||
| (`detach_node` or `remove_node`) must be run on the node being removed. | ||
|
|
||
| !!! hint | ||
|
|
||
| Zodan simplifies removing partially added nodes created during failed | ||
| node add operations. Additional cleanup steps may be required before | ||
| attempting another node deployment on the target host. | ||
|
|
||
| !!! note | ||
|
|
||
| Each script must be run from the target node being added or removed. | ||
| Zodan simplifies removing partially added nodes created during failed node | ||
| add operations. Additional cleanup steps may be required before attempting | ||
| another node deployment on the target host. | ||
|
|
||
| ## Key Differences Between using Zodan and the Manual Process | ||
|
|
||
| The following differences highlight how Zodan automates and simplifies | ||
| node addition: | ||
| The following differences highlight how Zodan automates and simplifies node | ||
| addition: | ||
|
|
||
| - Zodan stores sync LSNs and uses them later to ensure subscriptions | ||
| start from the correct point even if hours pass between steps. | ||
| - Zodan stores sync LSNs and uses them later to ensure subscriptions start | ||
| from the correct point even if time passes between steps. | ||
|
|
||
| - Zodan automatically detects existing schemas on the new node and populates the | ||
| `skip_schema` parameter, preventing conflicts during structure sync. | ||
| - Zodan verifies all nodes run a compatible Spock version before starting. | ||
|
|
||
| - Zodan verifies all nodes run the same Spock version before starting. | ||
|
|
||
| - Zodan includes the `verify_subscription_replicating()` function after | ||
| enabling subscriptions to ensure they reach replicating status. | ||
| - Zodan waits for each new subscription to reach the replicating state before | ||
| proceeding. | ||
|
|
||
| - When adding to a single-node cluster, Zodan handles the process | ||
| differently — no disabled subscriptions are needed. | ||
|
|
||
| - Zodan shows final status of all nodes and subscriptions across the | ||
| entire cluster, not just the new node. | ||
| differently, since no disabled subscriptions are needed. | ||
|
|
||
| - With the in-core procedures, every internal wait is bounded by the | ||
| `timeout_sec` argument (default 180 seconds), so a join that cannot make | ||
| progress fails quickly instead of blocking. Pass a larger `timeout_sec` if | ||
| your environment needs more headroom. | ||
|
|
||
| For more information, review the following resources: | ||
|
|
||
| - [Using Zodan](zodan_readme.md) | ||
| - [Zodan Tutorial](zodan_tutorial.md) | ||
| - [Zodan Scripts and Workflows](https://github.com/pgEdge/spock/tree/main/samples/Z0DAN) | ||
| - [Spock Documentation](https://docs.pgedge.com/spock-v5/) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.