mirror of https://github.com/citusdata/citus.git
This commit introduces the functionality to promote a streaming replica to a
primary node and rebalance the shards between the original primary and the
newly promoted node.
The key changes include:
- **New UDF `citus_promote_replica_and_rebalance`**:
This function orchestrates the entire process. It blocks writes on
the primary, waits for the replica to catch up, promotes the replica,
updates its metadata to a primary node, and then rebalances
the shards between the two nodes.
- **New UDF `get_snapshot_based_node_split_plan`**:
This function provides a preview of how the shards will be distributed
between the primary and the replica after the promotion and rebalancing,
allowing users to inspect the plan before execution.
- **Core Logic for Promotion and Rebalancing**:
- node_promotion.c: Contains the implementation for the promotion logic,
including checking replication lag and calling `pg_promote`.
- shard_rebalancer.c: Extended to calculate the shard distribution plan for the two-node split.
- shard_transfer.c: Includes logic to adjust shard placements in the metadata after the split.
- node_metadata.c: Updated to handle the activation of a replica as a new primary node.
This commit enables to execute the happy path for snapshot-based node split in Citus.
While the test cases and code cleanup are still remaining, the core functionality is in place
and can be tested.
|
||
|---|---|---|
| .. | ||
| backend | ||
| include | ||
| test | ||