citus/src
Muhammad Usama 56f7249704 Implement snapshot-based node split by promoting a replica
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.
2025-07-01 23:58:14 +05:00
..
backend Implement snapshot-based node split by promoting a replica 2025-07-01 23:58:14 +05:00
include Implement snapshot-based node split by promoting a replica 2025-07-01 23:58:14 +05:00
test Add skip_qualify_public param to shard_name() to allow qualifying for "public" schema (#8014) 2025-06-02 10:15:32 +03:00