[ https://issues.apache.org/jira/browse/KAFKA-463?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13455942#comment-13455942 ]
Jun Rao commented on KAFKA-463: ------------------------------- Thanks for patch v2. Some more comments: 20. Log: 20.1 rollSegment can be used for rolling the very first segment with offset 0 in the constructor too. Also, add a new line after rollSegment() 20.2 The following log message is bit confusing since Log shouldn't understand hw. Let's changed it to something more generic. error("Last checkpointed hw %d cannot be greater than the latest message offset %d in the log %s". format(targetOffset, segments.view.last.absoluteEndOffset, segments.view.last.file.getAbsolutePath)) 21. SegmentList: 21.1 The comment of truncLast is wrong. It's truncating everything from newOffset+1 to the end. 21.2 truncLast(): It's better to make sure that newOffset is >=0. Then we don't need the code max(newEnd + 1, 0). 21.3 It is true that callers of trunc and truncLast are already sync-ed on log.lock. All we need is to create a memory boundary so that the updated reference of contents are exposed to other threads. AtomicReference guarantees this. However, we could just use a volatile var. We can probably leave AtomicReference for now since the overhead shouldn't be too much. However, we probably don't need to use compareAndSet in trunc() and truncLast(). We can just use set and get rid of the loop. > log.truncateTo needs to handle targetOffset smaller than the lowest offset in > the log > ------------------------------------------------------------------------------------- > > Key: KAFKA-463 > URL: https://issues.apache.org/jira/browse/KAFKA-463 > Project: Kafka > Issue Type: Bug > Components: core > Reporter: Jun Rao > Assignee: Swapnil Ghike > Priority: Blocker > Labels: bugs > Fix For: 0.8 > > Attachments: kafka-463-v1.patch, kafka-463-v2.patch > > Original Estimate: 48h > Remaining Estimate: 48h > > When this happens, we should truncate all existing log segments. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira