github-advanced-security[bot] commented on code in PR #19311:
URL: https://github.com/apache/druid/pull/19311#discussion_r3273016198


##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/indexing/ShareGroupIndexerCrashIT.java:
##########
@@ -0,0 +1,273 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.testing.embedded.indexing;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.druid.data.input.impl.CsvInputFormat;
+import org.apache.druid.data.input.impl.DimensionsSpec;
+import org.apache.druid.data.input.impl.TimestampSpec;
+import org.apache.druid.indexer.granularity.UniformGranularitySpec;
+import org.apache.druid.indexing.kafka.KafkaIndexTaskModule;
+import org.apache.druid.indexing.kafka.KafkaIndexTaskTuningConfig;
+import org.apache.druid.indexing.kafka.ShareGroupIndexTask;
+import org.apache.druid.indexing.kafka.ShareGroupIndexTaskIOConfig;
+import org.apache.druid.jackson.DefaultObjectMapper;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.granularity.Granularities;
+import org.apache.druid.query.DruidMetrics;
+import org.apache.druid.segment.indexing.DataSchema;
+import org.apache.druid.testing.embedded.EmbeddedBroker;
+import org.apache.druid.testing.embedded.EmbeddedCoordinator;
+import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.EmbeddedHistorical;
+import org.apache.druid.testing.embedded.EmbeddedIndexer;
+import org.apache.druid.testing.embedded.EmbeddedOverlord;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Verifies at-least-once semantics: uncommitted records are redelivered after 
Indexer crash.
+ */
+public class ShareGroupIndexerCrashIT extends EmbeddedClusterTestBase
+{
+  private static final long SHARE_CONSUMER_READY_DELAY_MS = 3_000L;
+  private static final String COL_TIMESTAMP = "__time";
+  private static final String COL_ITEM = "item";
+  private static final String COL_VALUE = "value";
+  private static final String GROUP_ID = "crash-it-group";
+
+  private final EmbeddedCoordinator coordinator = new EmbeddedCoordinator();
+  private final EmbeddedOverlord overlord = new EmbeddedOverlord();
+  private final EmbeddedIndexer indexer = new EmbeddedIndexer();
+  private final EmbeddedHistorical historical = new EmbeddedHistorical();
+  private final EmbeddedBroker broker = new EmbeddedBroker();
+
+  private ShareGroupKafkaResource kafkaServer;
+  private final ObjectMapper mapper = new DefaultObjectMapper();
+
+  @Override
+  public EmbeddedDruidCluster createCluster()
+  {
+    kafkaServer = new ShareGroupKafkaResource();
+    final EmbeddedDruidCluster cluster = 
EmbeddedDruidCluster.withEmbeddedDerbyAndZookeeper();
+    indexer.addProperty("druid.segment.handoff.pollDuration", "PT0.1s");
+    cluster.addExtension(KafkaIndexTaskModule.class)
+           .addResource(kafkaServer)
+           .useLatchableEmitter()
+           .useDefaultTimeoutForLatchableEmitter(60)
+           .addCommonProperty("druid.monitoring.emissionPeriod", "PT0.1s")
+           .addServer(coordinator)
+           .addServer(overlord)
+           .addServer(indexer)
+           .addServer(historical)
+           .addServer(broker);
+    return cluster;
+  }
+
+  @Test
+  public void test_indexerCrash_midIngestion_noDataLossAfterRecovery() throws 
Exception
+  {
+    final String topic = dataSource + "_crash_topic";
+    kafkaServer.createTopicWithPartitions(topic, 1);
+    kafkaServer.setShareGroupAutoOffsetReset(GROUP_ID, "earliest");
+
+    // Produce all records before starting task so Indexer is polling them 
when it crashes.
+    final int batchA = 20;
+    kafkaServer.publishRecordsToTopic(topic, csvRecords(batchA, 0, 
"2025-09-01"));
+
+    // Task 1: starts ingesting but Indexer crashes before it completes.
+    final String taskId1 = submitTask(topic);

Review Comment:
   ## CodeQL / Unread local variable
   
   Variable 'String taskId1' is never read.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/11242)



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