xiangfu0 commented on code in PR #19888: URL: https://github.com/apache/pinot/pull/19888#discussion_r4636948301
########## 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: Fixed in 8733dc68915055d8c50b4f8391efea6ef1690ab7 after rebasing onto the #19235 merge commit. Controller, server and minion now require Helix's synchronous INIT callback to finish applying the snapshot before startup succeeds. An empty snapshot is valid. If registration returns without INIT, the role disables ingestion Groovy, disconnects and releases its startup resources. A late callback during disconnect cannot re-enable ingestion Groovy. The focused JDK 25 tests exercise the missing callback, an empty snapshot, and cleanup during disconnect. The server rollback also keeps existing segment-build leases alive on a co-located server hosting the same table. -- 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]
