title: Kafka Log compaction returns two records with the same key
body: <p>I am having a strange behaviour with log compaction in kafka. I have created a topic with the following configuration:</p>
  
  <pre><code>kafka-topics --zookeeper ... \
  --create --topic myTopic \
  --partitions 12 \
  --replication-factor 3 \
  --config "min.insync.replicas=2" \
  --config "cleanup.policy=compact" \
  --config "delete.retention.ms=100" \
  --config "retention.bytes=-1" \
  --config "segment.ms=100" \
  --config "min.cleanable.dirty.ratio=0.000001" \
  --config "min.compaction.lag.ms=10"
  </code></pre>
  
  <p>I send messages with the same key to the topic, and when the compation launches, it returns the last two message of this topic.</p>
  
  <p>Example:</p>
  
  <pre><code>Writting message with key="1" and value="A" into topic "myTopic"
  Writting message with key="1" and value="B" into topic "myTopic"
  Writting message with key="1" and value="C" into topic "myTopic"
  </code></pre>
  
  <p>COMPACTION</p>
  
  <p>print 'myTopic' from beginning</p>
  
  <p>{"ROWTIME":1549444994905,"ROWKEY":"1","value=B"}
  {"ROWTIME":1549444994905,"ROWKEY":"1","value=C"}</p>
  
  <pre><code>Writting message with key="1" and value="D" into topic "myTopic"
  </code></pre>
  
  <p>COMPACTION</p>
  
  <p>print 'myTopic' from beginning</p>
  
  <p>{"ROWTIME":1549444994905,"ROWKEY":"1","value=C"}
  {"ROWTIME":1549444994905,"ROWKEY":"1","value=D"}</p>
  
  <p>The same with segment.ms=60000</p>
  
  <p>Any idea?</p>
  
  <p>Thanks!!</p>