title: How does Confluent Replicator's offset translation deal with clock skew?
body: <p>I've been reading through the <a href="https://docs.confluent.io/platform/current/multi-dc-deployments/replicator/replicator-failover.html" rel="nofollow noreferrer">Confluent Replicator's docs</a> in order to evaluate its active-active multi-datacenter replication support and while the documentation is clear on the mechanism it uses to <a href="https://docs.confluent.io/platform/current/multi-dc-deployments/replicator/replicator-failover.html#understanding-consumer-offset-translation" rel="nofollow noreferrer">translate the consumer offset</a> from one DC to another what remains unclear to me is how that mechanism deals with clock skew.</p>
  <p>From what I can tell by reading <a href="https://www.confluent.io/white-paper/disaster-recovery-for-multi-datacenter-apache-kafka-deployments/" rel="nofollow noreferrer">the data recovery whitepaper</a> the message timestamps used for translation are actually <code>CreateTime</code> timestamps coming from the producers. However, all the examples that are given for how the offset translation is performed seem to imply that the timestamps are monotonically increasing, e.g. <a href="https://www.confluent.io/blog/15-facts-about-confluent-replicator-and-multi-cluster-kafka-deployment/#replicator-helps-applications" rel="nofollow noreferrer">this replicator blog post</a>:</p>
  <p><a href="https://i.stack.imgur.com/UgW9s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UgW9s.png" alt="Consumer offset translation using timestamps" /></a></p>
  <p>Why is this an issue? Because it is very hard (read: practically impossible) to guarantee monotonically increasing timestamps in distributed systems running on commodity hardware, and even with specialized hardware (e.g. AWS Time Sync Service) the best you can do is minimize the skew if you don't want to use a global time service similar to Google Spanner's TrueTime.</p>
  <p>So, let's consider the simplest scenario where DC-1 and DC-2 have been set up with active-active replication using separate topics, e.g. topic dc1-foo in DC-1 is replicated to dc1-foo in DC2 and dc2-foo from DC2 is replicated to d2-foo in DC-1. Let's also assume that the datacenters have been operating correctly from the start but that the replication of dc-1-foo has experienced a minor hiccup which caused some records to be duplicated in DC-2, making the offset in DC-2 greater than the offset in DC-1.</p>
  <p>Given the current comitted offset in DC-1 is O1 and DC-2 is O3, and given the contents for dc1-foo (in offset:TS format) is:</p>
  <ul>
  <li>DC-1: [O1:T3], [O2:T2], [O3:T3], [O4:T1], [O5:T3]</li>
  <li>DC-2: [O3:T3], [O4:T2], [O5:T3], [O6:T1], [O7:T3]</li>
  </ul>
  <p>When the consumer in DC-1 commits...</p>
  <ol>
  <li>offset O2, is the DC-2 offset translated to O4?</li>
  <li>offset O5, is the DC-2 offset translated to O3, O5 or O7?</li>
  </ol>
  <p>My guess would be that the translated offsets are O4 and O3 but just wanted to confirm.</p>