shihchengwei-lab commented on PR #20399:
URL: https://github.com/apache/pinot/pull/20399#issuecomment-7223673877

   An uploaded LLC segment without offsets makes controller partition repair 
fail.
   
   On `277b8b0979fe93c0377e4b3841429994ff08f956`, I used the `ZKOperatorTest` 
controller/Helix fixture to upload an LLC-named tar with a valid timestamp row, 
no offsets, and a sequence number higher than the current consuming segment. 
HTTP returned 200; ZK metadata kept both offsets `null`, and IdealState 
assigned the segment `ONLINE`. `ensureAllPartitionsConsuming()` then failed at 
[start-offset 
parsing](https://github.com/apache/pinot/blob/277b8b0979fe93c0377e4b3841429994ff08f956/pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/realtime/PinotLLCRealtimeSegmentManager.java#L304)
 with `NumberFormatException: Cannot parse null string` (wrapped after 
retries). It added no successor to IdealState. If this is the latest segment 
and its partition has no active consumer, the controller cannot repair that 
partition.
   
   <details>
   <summary>Minimal reproduction in ZKOperatorTest</summary>
   
   Add imports for `FileUploadDownloadClient` and `StreamConfig`, then add this 
method to the existing `ZKOperatorTest` fixture:
   
   ```java
   @Test
   public void testReviewHttpUploadOffsetFreeLlcThenRepair() throws Exception {
     String name = new LLCSegmentName(RAW_TABLE_NAME, 0, 1000, 
System.currentTimeMillis()).getSegmentName();
     File outputDir = new File(SEGMENT_DIR, "offsetFreeLlc");
     Schema schema = new Schema.SchemaBuilder().setSchemaName(RAW_TABLE_NAME)
         .addDateTime(TIME_COLUMN, DataType.TIMESTAMP, 
"1:MILLISECONDS:TIMESTAMP", "1:MILLISECONDS")
         .addSingleValueDimension("colA", DataType.INT).build();
     TableConfig generatorTable = new 
TableConfigBuilder(TableType.OFFLINE).setTableName(RAW_TABLE_NAME)
         .setTimeColumnName(TIME_COLUMN).build();
     SegmentGeneratorConfig config = new SegmentGeneratorConfig(generatorTable, 
schema);
     config.setOutDir(outputDir.getAbsolutePath());
     config.setSegmentName(name);
     GenericRow row = new GenericRow();
     row.putValue(TIME_COLUMN, System.currentTimeMillis());
     row.putValue("colA", 100);
     SegmentIndexCreationDriverImpl driver = new 
SegmentIndexCreationDriverImpl();
     driver.init(config, new GenericRowRecordReader(List.of(row)));
     driver.build();
     File tar = new File(SEGMENT_DIR, name + 
TarCompressionUtils.TAR_GZ_FILE_EXTENSION);
     TarCompressionUtils.createCompressedTarFile(new File(outputDir, name), 
tar);
   
     try (FileUploadDownloadClient client = new FileUploadDownloadClient()) {
       
assertEquals(client.uploadSegment(URI.create(TEST_INSTANCE.getAdminClient().getSegmentUploadUrl()),
           tar.getName(), tar, RAW_TABLE_NAME, 
TableType.REALTIME).getStatusCode(), 200);
     }
     SegmentZKMetadata metadata = 
_resourceManager.getSegmentZKMetadata(REALTIME_TABLE_NAME, name);
     assertEquals(metadata.getStatus(), Status.UPLOADED);
     assertNull(metadata.getStartOffset());
     assertNull(metadata.getEndOffset());
     IdealState state = 
_resourceManager.getTableIdealState(REALTIME_TABLE_NAME);
     assertTrue(state.getInstanceStateMap(name).containsValue("ONLINE"));
   
     try {
       
_resourceManager.getRealtimeSegmentManager().ensureAllPartitionsConsuming(REALTIME_TABLE_CONFIG,
           List.of(new StreamConfig(REALTIME_TABLE_NAME, getStreamConfigs())), 
null);
       fail("Expected repair to fail on the missing offset");
     } catch (RuntimeException expected) {
       IdealState afterRepair = 
_resourceManager.getTableIdealState(REALTIME_TABLE_NAME);
       
assertFalse(afterRepair.getRecord().getMapFields().keySet().stream().anyMatch(segment
 ->
           new LLCSegmentName(segment).getPartitionGroupId() == 0
               && new LLCSegmentName(segment).getSequenceNumber() > 1000));
     }
   }
   ```
   
   Run the focused case with:
   
   ```text
   mvn -B -ntp -pl pinot-controller -am 
-Dtest=ZKOperatorTest#testReviewHttpUploadOffsetFreeLlcThenRepair 
-Dsurefire.failIfNoSpecifiedTests=false test
   ```
   
   The focused test passes on this commit because it asserts the failed repair 
and absence of a successor.
   
   </details>
   
   The new 
[`SegmentZKMetadataUtilsTest`](https://github.com/apache/pinot/blob/277b8b0979fe93c0377e4b3841429994ff08f956/pinot-common/src/test/java/org/apache/pinot/common/metadata/segment/SegmentZKMetadataUtilsTest.java#L35-L58)
 checks only ZK metadata creation. It does not cover upload, assignment, or 
repair. The existing 
[`ZKOperatorTest.testPushToRealtimeTable`](https://github.com/apache/pinot/blob/277b8b0979fe93c0377e4b3841429994ff08f956/pinot-controller/src/test/java/org/apache/pinot/controller/api/upload/ZKOperatorTest.java#L349-L359)
 still expects an offset-free LLC upload to be rejected. Could this path 
establish a usable resume offset or handle its absence before the segment 
becomes the latest, with a test covering upload through repair?
   
   AI assisted with the code review, reproduction test design, and wording. I 
ran the HTTP upload and controller repair case against the commit above.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to