jt2594838 commented on code in PR #18557:
URL: https://github.com/apache/iotdb/pull/18557#discussion_r3900477892


##########
iotdb-core/consensus/src/test/java/org/apache/iotdb/consensus/iot/logdispatcher/SyncStatusTest.java:
##########
@@ -242,4 +248,53 @@ public void waitTest() throws InterruptedException, 
ExecutionException {
     Assert.assertEquals(
         config.getReplication().getMaxPendingBatchesNum() + 1, 
status.getNextSendingIndex());
   }
+
+  @Test
+  public void testFirstBatchRetriesMemoryReservation()
+      throws InterruptedException, ExecutionException, TimeoutException {
+    IndexController controller =
+        new IndexController(storageDir.getAbsolutePath(), peer, 0, 
CHECK_POINT_GAP);
+    IoTConsensusConfig retryConfig =
+        IoTConsensusConfig.newBuilder()
+            .setReplication(
+                
IoTConsensusConfig.Replication.newBuilder().setBasicRetryWaitTimeMs(10).build())
+            .build();
+    SyncStatus status = new SyncStatus(controller, retryConfig);
+    TLogEntry logEntry = new TLogEntry().setSearchIndex(1).setMemorySize(1);
+    Batch batch = new Batch(retryConfig);
+    batch.addTLogEntry(logEntry);
+    batch.buildIndex();
+
+    IoTConsensusMemoryManager memoryManager = 
IoTConsensusMemoryManager.getInstance();
+    long previousMaxMemory = memoryManager.getMaxMemorySizeInByte();
+    long previousMaxQueueMemory = 
memoryManager.getMaxMemorySizeForQueueInByte();
+    ExecutorService executor = Executors.newSingleThreadExecutor();
+    CountDownLatch taskStarted = new CountDownLatch(1);
+    memoryManager.init(0, 0);

Review Comment:
   This regression test forces the first reservation to fail with zero memory, 
verifies the writer remains pending, then raises the limit and requires 
completion within a timeout. It deterministically covers the retry path and 
restores the singleton memory-manager limits, executor, and SyncStatus state in 
finally so it remains isolated from neighboring tests. The targeted consensus 
Maven test suite passed with zero failures.



-- 
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]

Reply via email to