DEV Community

Michael
Michael

Posted on • Originally published at gbase.cn

How Distribution Tables Keep Data Consistent When Replacing a Data Node

When you swap a failed Data Node with a fresh one in GBase 8a, a carefully choreographed sequence ensures data distribution stays consistent: a transitional distribution map isolates the fault, then an automatically rebuilt map restores the original layout while data is moved in the background. The key is a two‑table relay that guarantees a complete, valid mapping exists at every moment.

The Four‑Step Process

  1. Create a transitional distribution map — The DBA manually builds a new distribution that excludes the failed node. The cluster now holds two maps: the original (with the failed node) and the transitional (without it).
  2. Trigger the replacement command — The system automatically creates a third distribution map. This one is identical to the original, except the failed node's IP is replaced by the new node's IP.
  3. Data migration and switchover — The system moves data from the transitional map's nodes to the new node according to the automatically created map. Once complete, the original map is deleted.
  4. Final state — Two maps remain: the transitional one (which you can drop manually) and the final one that mirrors the original layout.

How Consistency Is Guaranteed

Preparation Phase: Logical Consistency

The DBA exports the original distribution, removes all segments belonging to the failed node (promoting backup segments to primary where necessary), and creates the transitional map.

  • Segment integrity: Every data segment retains exactly one primary copy — no segment is lost.
  • Continuous access: All data stays accessible through the transitional map.

Execution Phase: Physical Consistency

The system reconstructs a final distribution map that matches the original layout exactly, with only the node IP changed. Data is synchronously copied from the transitional map's nodes to the new node. Once migration finishes, the original map is automatically dropped.

  • Mapping continuity: The final map inherits the complete, original distribution policy — only the physical IP differs.
  • Atomic switch: The map swap is atomic; the final map becomes active and the old one is removed only after all data is safely moved. No window of inconsistency exists.
  • Zero data loss: Migration is a synchronous copy; old mappings are invalidated only after the corresponding data is fully replicated.

Cleanup Phase: Final Convergence

The DBA runs rebalance and refreshnodedatamap drop, then deletes the transitional map. At this point all data already resides under the final map — removing the transitional map is pure metadata housekeeping.

The Big Picture: A Multi‑Version Distribution State Machine

This entire procedure is a state machine evolving distribution maps from original → transitional + rebuilt → final. By maintaining multiple map versions and carefully ordering their activation and retirement, GBase 8a guarantees that at least one complete, correct distribution map always guides data access. The IP change becomes a seamless metadata version switch — completely transparent to applications and safe for your gbase database.

Top comments (0)