01 / 04

Explain the replication handshake and partial resync (PSYNC2).

On connect, replica sends PSYNC <replid> <offset>. If the master's backlog contains that offset, it sends only the delta (partial resync). Otherwise, it triggers a full resync (BGSAVE + stream). Redis 4's PSYNC2 allows partial resync after failover using secondary replication IDs.