junrao commented on code in PR #12516:
URL: https://github.com/apache/kafka/pull/12516#discussion_r950387484


##########
core/src/main/scala/kafka/log/LogSegment.scala:
##########
@@ -176,10 +179,28 @@ class LogSegment private[log] (val log: FileRecords,
       throw new LogSegmentOffsetOverflowException(this, offset)
   }
 
+  /**
+   * Validate that offsets of records are monotonically increasing and are in 
[offsetLowerBound, offsetUpperBound] range.
+   *
+   * @param records The log records to validate
+   * @param offsetLowerBound The lower bound of offsets of all records 
(inclusive)
+   * @param offsetUpperBound The upper bound of offsets of all records 
(inclusive)
+   */
+  private def ensureOffsetsInRangeForRecords(records: Records, 
offsetLowerBound: Long, offsetUpperBound: Long): Unit = {
+    var offsetLowerBoundForBatch = offsetLowerBound
+    records.batches.forEach { batch =>
+      if (batch.baseOffset < offsetLowerBoundForBatch || batch.lastOffset > 
offsetUpperBound || batch.baseOffset > batch.lastOffset) {

Review Comment:
   Was the issue reported issue in the jira on the leader or the follower?  If 
it's on the leader, currently, each leader append only has one batch. I am 
wondering if the validation should be done inside 
LogValidator.validateMessagesAndAssignOffsets.



##########
core/src/main/scala/kafka/log/LogSegment.scala:
##########
@@ -176,10 +179,28 @@ class LogSegment private[log] (val log: FileRecords,
       throw new LogSegmentOffsetOverflowException(this, offset)
   }
 
+  /**
+   * Validate that offsets of records are monotonically increasing and are in 
[offsetLowerBound, offsetUpperBound] range.

Review Comment:
   We are just verifying the offsets of record batches, not individual records.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to