Jackie-Jiang commented on code in PR #19888: URL: https://github.com/apache/pinot/pull/19888#discussion_r4636619839
########## pinot-common/src/main/java/org/apache/pinot/common/utils/config/IngestionGroovyConfigListener.java: ########## @@ -0,0 +1,69 @@ +/** + * 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.pinot.common.utils.config; + +import java.util.Map; +import java.util.Set; +import org.apache.helix.HelixManager; +import org.apache.helix.api.listeners.ClusterConfigChangeListener; +import org.apache.pinot.common.evaluator.GroovyFunctionEvaluator; +import org.apache.pinot.spi.config.provider.PinotClusterConfigChangeListener; +import org.apache.pinot.spi.utils.CommonConstants.Groovy; + + +/// Applies the cluster ingestion Groovy policy in server and minion processes. +/// +/// Missing, removed, and invalid values disable new ingestion compilation; only `false` enables it. Query Groovy +/// and previously compiled scripts retain their own behavior. Thread-safe: updates publish through a volatile flag. +public class IngestionGroovyConfigListener implements PinotClusterConfigChangeListener { + @Override + public void onChange(Set<String> changedConfigs, Map<String, String> clusterConfigs) { + applyClusterConfig(clusterConfigs); + } + + /// Applies a raw cluster snapshot before a server or minion starts ingestion or query processing. + public static void applyClusterConfig(Map<String, String> clusterConfigs) { + GroovyFunctionEvaluator.setIngestionGroovyDisabled( + Groovy.isIngestionGroovyDisabled(clusterConfigs.get(Groovy.DISABLE_INGESTION_GROOVY))); + } + + /// Subscribes a runtime role to cluster updates. On failure, disables ingestion compilation, disconnects the + /// participant, and releases initialized role resources before failing startup with the original cause. + public static void subscribeToClusterConfig(HelixManager helixManager, ClusterConfigChangeListener listener, + Runnable... failureCleanup) { + try { + helixManager.addClusterfigChangeListener(listener); Review Comment: [P2] Could we require acknowledgment that the initial policy callback completed before treating registration as successful? In Helix 2.0.1, CallbackHandler.init() catches and logs watch-installation and initial-read exceptions, so addClusterfigChangeListener() can return normally without invoking the listener. I reproduced this against the actual CallbackHandler with a ZkTimeoutException from subscribeDataChanges: one watch attempt, zero callbacks, and normal constructor return. A short zk.operation.retry.timeout.ms can expire before the session does; a same-session reconnect does not necessarily initialize the missed watch. The service can therefore start with the earlier enabled policy and miss subsequent disable updates until successful reinitialization. The current tests mock an exception from addClusterfigChangeListener itself, which misses this failure path. ########## pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java: ########## @@ -3312,13 +3313,21 @@ public static class IngestionConfigs { public static final int DEFAULT_INGESTION_EXCEPTION_LOG_RATE_LIMIT_PER_MIN = 5; } - /// Configuration for setting up groovy static analyzer. + /// Configuration for ingestion Groovy and the Groovy static analyzer. /// User can config different configuration for query and ingestion (table creation and update) static analyzer. /// The all configuration is the default configuration for both query and ingestion static analyzer. public static class Groovy { + /// Cluster-only switch for ingestion Groovy. Query Groovy remains independently controlled. + public static final String DISABLE_INGESTION_GROOVY = "controller.disable.ingestion.groovy"; Review Comment: Nonblocking naming suggestion: since this policy now applies to controllers, servers, and minions, could we remove the controller-specific prefix? For example, pinot.groovy.ingestion.disabled would fit the neighboring pinot.groovy.* settings. Please retain controller.disable.ingestion.groovy as a deprecated alias with explicit precedence, rather than renaming it outright, and keep the legacy key usable during rolling upgrades. -- 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]
