jihoonson commented on a change in pull request #7246: Fix record validation in 
SeekableStreamIndexTaskRunner
URL: https://github.com/apache/incubator-druid/pull/7246#discussion_r264981163
 
 

 ##########
 File path: 
indexing-service/src/main/java/org/apache/druid/indexing/seekablestream/SeekableStreamIndexTaskRunner.java
 ##########
 @@ -1882,33 +1882,35 @@ TransactionalSegmentPublisher 
createPublisher(TaskToolbox toolbox, boolean useTr
   }
 
   private boolean verifyInitialRecordAndSkipExclusivePartition(
-      final OrderedPartitionableRecord<PartitionIdType, SequenceOffsetType> 
record,
-      final Map<PartitionIdType, SequenceOffsetType> intialSequenceSnapshot
+      final OrderedPartitionableRecord<PartitionIdType, SequenceOffsetType> 
record
   )
   {
-    if (intialSequenceSnapshot.containsKey(record.getPartitionId())) {
-      if 
(record.getSequenceNumber().compareTo(intialSequenceSnapshot.get(record.getPartitionId()))
 < 0) {
-        throw new ISE(
-            "Starting sequenceNumber [%s] does not match expected [%s] for 
partition [%s]",
-            record.getSequenceNumber(),
-            intialSequenceSnapshot.get(record.getPartitionId()),
-            record.getPartitionId()
+    // Check only for the first record among the record batch.
+    if (initialOffsetsSnapshot.contains(record.getPartitionId())) {
+      final SequenceOffsetType currOffset = 
currOffsets.get(record.getPartitionId());
+      if (currOffset != null) {
+        final OrderedSequenceNumber<SequenceOffsetType> recordSequenceNumber = 
createSequenceNumber(
+            record.getSequenceNumber()
+        );
+        final OrderedSequenceNumber<SequenceOffsetType> currentSequenceNumber 
= createSequenceNumber(
+            currOffset
         );
+        if (recordSequenceNumber.compareTo(currentSequenceNumber) < 0) {
+          throw new ISE(
+              "sequenceNumber of the start record[%s] is smaller than current 
sequenceNumber[%s] for partition [%s]",
+              record.getSequenceNumber(),
+              currOffset,
+              record.getPartitionId()
+          );
+        }
       }
 
-      log.info(
-          "Verified starting sequenceNumber [%s] for partition [%s]",
-          record.getSequenceNumber(), record.getPartitionId()
-      );
-
-      intialSequenceSnapshot.remove(record.getPartitionId());
-      if (intialSequenceSnapshot.isEmpty()) {
-        log.info("Verified starting sequences for all partitions");
-      }
+      // Remove the mark to notify that this partition has been read.
+      initialOffsetsSnapshot.remove(record.getPartitionId());
 
       // check exclusive starting sequence
       if (isStartingSequenceOffsetsExclusive() && 
exclusiveStartingPartitions.contains(record.getPartitionId())) {
-        log.info("Skipping starting sequenceNumber for partition [%s] marked 
exclusive", record.getPartitionId());
+        log.warn("Skipping starting sequenceNumber for partition [%s] marked 
exclusive", record.getPartitionId());
 
 Review comment:
   Hmm, I don't remember why I changed this.. Will revert.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to