# About the processing logic of the LWW part

**URL:** <https://forum.yugabyte.com/t/about-the-processing-logic-of-the-lww-part/1371>\
**Category:** General\
**Created:** [December 28, 2021, 8:21am UTC](https://forum.yugabyte.com/t/about-the-processing-logic-of-the-lww-part/1371 "2021-12-28T08:21:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Super-long](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/super-long/32/426_2.png) [@Super-long](https://forum.yugabyte.com/u/Super-long)\
**Post date:** [December 28, 2021, 8:21am UTC](https://forum.yugabyte.com/t/about-the-processing-logic-of-the-lww-part/1371/1 "2021-12-28T08:21:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [January 13, 2022, 10:33am UTC](https://forum.yugabyte.com/t/about-the-processing-logic-of-the-lww-part/1371/2 "2022-01-13T10:33:43Z")

</div>

@Super-long note that LWW (last write wins) is only applicable for asynchronous replication [Deploy | YugabyteDB Docs](https://docs.yugabyte.com/latest/deploy/multi-dc/async-replication/)

Also, please don’t start the same conversation in multiple places.

---

<div class="post-metadata">

**Author:** ![Super-long](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/super-long/32/426_2.png) [@Super-long](https://forum.yugabyte.com/u/Super-long)\
**Post date:** [January 13, 2022, 12:56pm UTC](https://forum.yugabyte.com/t/about-the-processing-logic-of-the-lww-part/1371/5 "2022-01-13T12:56:03Z")

</div>

@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)…

---

<div class="post-metadata">

**Author:** ![Alan\_Caldera](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/alan_caldera/32/91_2.png) [@Alan\_Caldera](https://forum.yugabyte.com/u/Alan_Caldera)\
**Post date:** [January 13, 2022, 1:33pm UTC](https://forum.yugabyte.com/t/about-the-processing-logic-of-the-lww-part/1371/6 "2022-01-13T13:33:15Z")

</div>

@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](https://github.com/yugabyte/yugabyte-db/tree/master/architecture/design) for additional details in the coming months.  
Hope this helps.
