Skip to content

Mixed-Cluster Live Slot Migration

In Standalone or Sentinel topologies, 1:1 node replacement is handled by attaching a replica and promoting it. Across a 16,384-slot Redis 7.2 or Valkey Cluster spanning 24 primary shards, consolidating down to 12 high-density Engula 2.3.0 shards online with zero client downtime relies on mixed-cluster live slot migration (CLUSTER SETSLOT + MIGRATE).


1. Unconditional Wire Contract: Standard RDB v11 + CRC64

Verified across serialization code paths and automated cross-engine interoperability suites (INTOP-08, INTOP-09, INTOP-10):

  • Wire framing is completely decoupled from local disk format: Regardless of whether local disk persistence uses engula-rdb 1 or 0, DUMP, MIGRATE, and RESTORE-ASKING unconditionally serialize standard logical RDB version 11 payloads with an 8-byte CRC64 checksum over the network.
  • Internal block encodings never leak onto the wire: Compressed memory blocks, shared dictionaries, and compact record headers never enter MIGRATE sockets; compressed interior List nodes transparently convert back to standard encodings on egress.
  • Verified mixed-cluster baseline: Across automated 6-shard mixed clusters (3 Engula 2.3.0 shards + 3 Redis 7.2.15 shards), CLUSTER MEET handshakes, cross-engine replica failovers, and bidirectional MIGRATE of 8 KB compressed records (8,192-byte exact restore, zero source residue, idempotent NOKEY retry) pass 100%. Official Engula 2.3.0 builds impose zero shard-count caps.

Three-Layer Cluster Decoupling & Slot Consensus

Cluster Subsystem Engineering Mechanism Live Resharding Behavior
Slot Index Layer (16,384 On-Demand Sub-Tables) Splits main and expiry indexes into 16,384 per-slot sub-tables allocated on first key write and freed when emptied Full 16,384-slot throughput matches standalone mode (222.2k RPS); CLUSTER COUNTKEYSINSLOT reads sub-table headers in constant time
Compact Block Pool (Instance-Wide Shared Blocks) All 16,384 slot sub-tables share the compact block pool and dictionary pipeline to preserve high cross-slot compression Draining a slot leaves sparse holes reclaimed asynchronously by background compaction coroutines
Compatibility Slot Consensus (Default Level 2) Default engula-redis7-compatibility-level 2 matches Redis 7.2 by keeping half-open migrating/importing flags local to primaries Guarantees uniform epoch progression and Gossip slot-ownership transitions across mixed stock and Engula shards

2. Live Shard Consolidation SOP (Example: 24 to 12 Primary Shards)

Step 1: Pin Configuration & Reserve 25%–30% Transient Write Buffer

Configure the 12 new Engula 2.3.0 primary/replica pairs with identical compatibility settings across the entire cluster:

1cluster-enabled yes
2cluster-config-file nodes.conf
3cluster-node-timeout 15000
4io-threads 4
5disable-thp yes
6enable-debug-command no
7engula-redis7-compatibility-mode yes
8engula-redis7-compatibility-level 2

Transient Headroom Sizing: Incoming RESTORE-ASKING keys append into plaintext mutable blocks before background coroutines train dictionaries and compress them. Reserve 25%–30% transient maxmemory headroom on destination shards so burst migration rates never outrun initial background compression and trigger OOM rejections.

Step 2: Join the Live Cluster with Zero Hash Slots

Add the 12 new primary/replica pairs into the existing cluster. Holding 0 hash slots, they receive zero client traffic upon joining:

1# Join a new primary and attach its replica
2redis-cli --cluster add-node 10.0.2.11:6379 10.0.1.11:6379
3redis-cli --cluster add-node 10.0.2.12:6379 10.0.1.11:6379 --cluster-slave --cluster-master-id <new-master-node-id>

Step 3: Migrate Slots in Waves & Enforce the Source-Zero Guard

Use your existing cluster orchestrator or redis-cli --cluster reshard in waves of 256 or 512 slots (clients hitting migrating slots follow standard -ASK redirection):

  1. Track half-open migration states via node output: In-flight migrating/importing markers appear in CLUSTER NODES (not CLUSTER SLOTS).
  2. Mandatory safety invariant — verify zero remaining keys on source before ownership broadcast: Before any automation script issues CLUSTER SETSLOT <slot> NODE <dst-node-id> on the destination primary, it must verify that the source primary reports exactly 0 remaining keys in that slot:
    1# Proceed to CLUSTER SETSLOT <slot> NODE <dst> ONLY when this returns 0!
    2redis-cli -h 10.0.1.11 -p 6379 CLUSTER COUNTKEYSINSLOT <slot>
    Why this matters: Issuing CLUSTER SETSLOT <slot> NODE <dst-node-id> directly on an importing destination while keys still reside on the source bumps the configuration epoch and broadcasts ownership cluster-wide—causing the source primary to treat remaining unmigrated keys in that slot as orphan dirty-slot data and delete them. If a source primary fails over mid-slot, run CLUSTER SETSLOT <slot> STABLE on the destination before resuming.

Step 4: Confirm Compression Convergence & Decommission Drained Nodes

Between 256–512-slot waves, confirm the destination compression queue has drained and used_memory_rss has settled:

1redis-cli -h 10.0.2.11 -p 6379 ENGULA INFO pipeline | grep engula_zip_queue_length
2redis-cli -h 10.0.2.11 -p 6379 INFO memory | grep used_memory_rss_human

Once legacy Redis 7.2 shards hold 0 slots and zero active client traffic, decommission replicas first and primaries second via CLUSTER FORGET <old-node-id>. Reversing the direction and resharding slots back onto stock Valkey or Redis 7.2 nodes works identically at any time.


3. Four Rate-Limiting & Operational Boundaries

  1. Bound per-call key batch sizes to 20–100 keys: Unlike constant-time CLUSTER COUNTKEYSINSLOT, CLUSTER GETKEYSINSLOT materializes key names from compact records (decompressing if the underlying block is compressed). Keep batch count at 20–100 keys (1–10 for 100 KB+ values) to avoid stalling the source main thread.
  2. Synchronous migration batch window & asynchronous source RSS decay: MIGRATE blocks the source main thread across each batch round-trip (keep --cluster-pipeline around 10–50). When an Engula node is the migration source, freed space across shared blocks returns to the OS asynchronously via background compaction and the ~1,000 ms block-arena decay window.
  3. Destination maxmemory OOM enforcement: RESTORE-ASKING rejects writes with OOM if effective memory hits maxmemory; pace migration throughput to match background compression.
  4. Deterministic Fail-Stop on block corruption: Any block checksum mismatch encountered during CLUSTER GETKEYSINSLOT or MIGRATE triggers immediate Fail-Stop containment and writes engula-corruption.marker rather than silently skipping damaged keys across shards (see Incident Triage & Fail-Stop Playbook).