Hello everyone, I am a newbie to yugabyte-DB. I try to find the processing logic of LWW when synchronizing data between multiple regions. I started with CDC, but I don’t know where to start after I get to SendNextCDCWriteToTablet. So in which file is the processing logic of LWW? Thank you very much.
@Super-long note that LWW (last write wins) is only applicable for asynchronous replication Deploy to two universes with asynchronous replication | YugabyteDB Docs
Also, please don’t start the same conversation in multiple places.
@dorian_yugabyte Thank you very much for your reply, I have noticed the description in the documentation, I just want to learn how LWW is implemented in the code (I spent a lot of effort and failed)…
@Super-long - So Xcluster (asynchronous replication based on CDC) takes advantage of the nature of our storage engine. When a write occurs, the values associated with the columns will be written with a specific hybrid time (combination of GPS time + Lamport clock). Now when the CDC is processed, the new records are appended to the tablets transaction log along with the hybrid time of that operation as expressed on the source of the transaction. So if the incoming transaction has a higher (later) hybrid time, it is the “winner” because when a subsequent transaction issues a read at a hybrid time later than the writes, the record / value with the highest hybrid time will be selected.
At a future point, there will likely be a transaction coordinator where additional processing of CDC records could be modified to support other processing semantics. Please watch Architecture Design documents for additional details in the coming months.
Hope this helps.