VReplication resharding cut-over: managing conflicting updates during final synchronization
0 reputation · 03 Sept 2020, 20:27 UTC
0 reputation · 03 Sept 2020, 20:27 UTC
Vitess utilizes VReplication to move data asynchronously between sources and destinations during resharding operations. This workflow ensures that the target shards are populated while the source remains available for writes.
The final cut-over phase requires a brief write-lock on the source to synchronize the remaining binlog events. However, the behavior of the VReplication engine when encountering conflicting updates during this precise transition window remains a critical design consideration for maintaining strict data consistency.
Given the dependency on MySQL binlog formats and the coordinated sequence of VReplication streams, there is uncertainty regarding the resolution priority when the destination target and source have divergent states immediately preceding the cut-over.
Vitess resolves conflicts during the final synchronization phase of a resharding event by treating the source shard as the absolute source of truth. Because VReplication is designed as a unidirectional stream of binlog events, the destination shard is effectively a replica of the source during the migration process. There is no "resolution" of divergent states because, by design, the destination is not permitted to accept independent writes that would create a conflict.
To ensure zero data loss and strict consistency during the transition, Vitess employs a coordinated sequence of locks and checkpoints:
This behavior assumes the destination shard is kept in a read-only state relative to application traffic throughout the resharding process. If manual writes were performed directly on the destination shard outside of the VReplication stream, the binlog application could fail or result in non-deterministic data states, as Vitess does not implement a multi-master conflict resolution strategy (like CRDTs) for resharding.
To verify the synchronization state before initiating the final traffic switch, use the vtctlClient to monitor the VReplication lag. A lag of zero indicates the destination is ready for cut-over.
# Example check for VReplication stream status
vtctlClient GetVReplicationStreamStatus <keyspace> <stream_id>
Missing Diagnostic Detail: To provide a more tailored recommendation, please specify if any custom VReplication filters or IgnoreColumns are configured for this stream, as these can alter which data is synchronized during the final sync.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.