Re: [PR] Support blacklist datanode dynamic config (druid)

2026-03-12 Thread via GitHub


jtuglu1 commented on PR #19136:
URL: https://github.com/apache/druid/pull/19136#issuecomment-4051741291

   Going to close this out in favor of the clone historicals feature. We can 
get close enough to what we need with that.


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



Re: [PR] Support blacklist datanode dynamic config (druid)

2026-03-12 Thread via GitHub


jtuglu1 closed pull request #19136: Support blacklist datanode dynamic config
URL: https://github.com/apache/druid/pull/19136


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



Re: [PR] Support blacklist datanode dynamic config (druid)

2026-03-12 Thread via GitHub


jtuglu1 commented on code in PR #19136:
URL: https://github.com/apache/druid/pull/19136#discussion_r2928252792


##
server/src/main/java/org/apache/druid/client/BrokerServerView.java:
##
@@ -99,6 +105,28 @@ public BrokerServerView(
 
 this.emitter = emitter;
 this.brokerViewOfCoordinatorConfig = brokerViewOfCoordinatorConfig;
+// Compose coordinator filter (clone semantics) with broker blacklist 
filter.
+// Coordinator filter is applied first, then blacklisted nodes are 
excluded from the result.
+this.compositeFilter = (servers, mode) -> {
+  final Int2ObjectRBTreeMap> afterCoordFilter =
+  brokerViewOfCoordinatorConfig.getQueryableServers(servers, mode);
+  final BrokerDynamicConfig brokerConfig = 
brokerViewOfBrokerConfig.getDynamicConfig();
+  if (brokerConfig == null || 
brokerConfig.getBlacklistedDataNodes().isEmpty()) {
+return afterCoordFilter;
+  }
+  final Set blacklisted = brokerConfig.getBlacklistedDataNodes();
+  final Int2ObjectRBTreeMap> result = new 
Int2ObjectRBTreeMap<>();

Review Comment:
   This might be a bit expensive – nlogn in # of servers (which hopefully 
shouldn't be too bad). It didn't show up in profiles.



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



Re: [PR] Support blacklist datanode dynamic config (druid)

2026-03-11 Thread via GitHub


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


##
embedded-tests/src/test/java/org/apache/druid/testing/embedded/server/EmbeddedBrokerDynamicConfigTest.java:
##
@@ -0,0 +1,166 @@
+/*
+ * 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.server;
+
+import com.google.common.collect.ImmutableSet;
+import org.apache.druid.common.utils.IdUtils;
+import org.apache.druid.indexing.common.task.TaskBuilder;
+import org.apache.druid.server.QueryBlocklistRule;
+import org.apache.druid.server.broker.BrokerDynamicConfig;
+import org.apache.druid.server.http.BrokerDynamicConfigSyncer;
+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.indexing.Resources;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import java.util.List;
+
+/**
+ * Integration test for broker dynamic configuration, covering {@code 
queryBlocklist}
+ * and {@code blacklistedDataNodes} features.
+ */
+public class EmbeddedBrokerDynamicConfigTest extends EmbeddedClusterTestBase
+{
+  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();
+
+  @Override
+  protected EmbeddedDruidCluster createCluster()
+  {
+indexer.addProperty("druid.segment.handoff.pollDuration", "PT0.1s");
+
+return EmbeddedDruidCluster.withEmbeddedDerbyAndZookeeper()
+   .useLatchableEmitter()
+   .addServer(overlord)
+   .addServer(coordinator)
+   .addServer(indexer)
+   .addServer(historical)
+   .addServer(broker);
+  }
+
+  @BeforeAll
+  @Override
+  public void setup() throws Exception
+  {
+super.setup();
+ingestData();
+cluster.callApi().waitForAllSegmentsToBeAvailable(dataSource, coordinator, 
broker);
+  }
+
+  @Test
+  @Timeout(30)
+  public void testQueryBlocklistBlocksMatchingQueries()
+  {
+// Baseline: query succeeds before blocklist is applied
+String initialResult = cluster.callApi().runSql("SELECT COUNT(*) FROM %s", 
dataSource);
+Assertions.assertFalse(initialResult.isBlank());
+
+// Apply blocklist rule that matches all queries on this datasource
+QueryBlocklistRule blockRule = new QueryBlocklistRule(
+"block-test-datasource",
+ImmutableSet.of(dataSource),
+null,
+null
+);
+updateBrokerDynamicConfig(
+BrokerDynamicConfig.builder()
+   .withQueryBlocklist(List.of(blockRule))
+   .build()
+);
+
+// Query should now throw due to FORBIDDEN blocklist rule
+Assertions.assertThrows(
+RuntimeException.class,
+() -> cluster.callApi().runSql("SELECT COUNT(*) FROM %s", dataSource)
+);
+
+// Clear the blocklist and verify queries resume
+updateBrokerDynamicConfig(BrokerDynamicConfig.builder().build());
+String finalResult = cluster.callApi().runSql("SELECT COUNT(*) FROM %s", 
dataSource);
+Assertions.assertFalse(finalResult.isBlank());
+  }
+
+  @Test
+  @Timeout(30)
+  public void testBlacklistedDataNodesExcludesNodesFromQueryRouting()
+  {
+// Baseline: query returns data
+String initialResult = cluster.callApi().runSql("SELECT COUNT(*) FROM %s", 
dataSource);
+int initialCount = Integer.parseInt

Re: [PR] Support blacklist datanode dynamic config (druid)

2026-03-11 Thread via GitHub


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


##
server/src/test/java/org/apache/druid/client/selector/ServerSelectorTest.java:
##
@@ -168,4 +174,67 @@
 Assert.assertTrue(selector.hasData());
   }
 
+  @Test
+  public void testFilterAppliedToRealtimeServers()
+  {
+final DataSegment segment = DataSegment.builder()

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [DataSegment.builder](1) should be avoided because it has been 
deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10878)



##
server/src/main/java/org/apache/druid/client/selector/ServerSelector.java:
##
@@ -155,7 +155,7 @@
   .forEach(candidates::add);
 
 if (candidates.size() < numCandidates) { //-V6007: false alarm due to 
a bug in PVS-Studio
-  realtimeTierStrategy.pick(realtimeServers, segment.get(), 
numCandidates - candidates.size())
+  
realtimeTierStrategy.pick(filter.getQueryableServers(realtimeServers, 
cloneQueryMode), segment.get(), numCandidates - candidates.size())

Review Comment:
   ## Deprecated method or constructor invocation
   
   Invoking [TierSelectorStrategy.pick](1) should be avoided because it has 
been deprecated.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/10877)



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