From c9311d5f4ec3b135cb6c0f87008da946863daaa2 Mon Sep 17 00:00:00 2001 From: Ismael Juma Date: Fri, 11 Mar 2016 17:53:32 -0800 Subject: [PATCH] KAFKA-3047: Explicit offset assignment in Log.append can corrupt the log This fix was suggested by Maciek Makowski, who also reported the problem. Author: Ismael Juma Reviewers: Guozhang Wang Closes #1029 from ijuma/KAFKA-3047-log-append-can-corrupt-the-log --- core/src/main/scala/kafka/log/Log.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/scala/kafka/log/Log.scala b/core/src/main/scala/kafka/log/Log.scala index fd176b1e9ea..8c956f7378f 100644 --- a/core/src/main/scala/kafka/log/Log.scala +++ b/core/src/main/scala/kafka/log/Log.scala @@ -328,11 +328,11 @@ class Log(val dir: File, try { // they are valid, insert them in the log lock synchronized { - appendInfo.firstOffset = nextOffsetMetadata.messageOffset if (assignOffsets) { // assign offsets to the message set val offset = new LongRef(nextOffsetMetadata.messageOffset) + appendInfo.firstOffset = offset.value val now = time.milliseconds val (validatedMessages, messageSizesMaybeChanged) = try { validMessages.validateMessagesAndAssignOffsets(offset,