This is an automated email from the ASF dual-hosted git repository.
Jackie-Jiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 2a07f212d76 Prevent Lucene class initialization deadlock during server
startup (#20296)
2a07f212d76 is described below
commit 2a07f212d76000945c110a1136a0b8f23bca6097
Author: Xiaotian (Jackie) Jiang <[email protected]>
AuthorDate: Wed Nov 18 13:31:15 2026 -0800
Prevent Lucene class initialization deadlock during server startup (#20296)
---
.../CompatibilityServerStarter.java | 46 +++++++++++++++++
compatibility-verifier/README.md | 7 +++
compatibility-verifier/compCheck.sh | 8 ++-
compatibility-verifier/server-startup.inc | 57 ++++++++++++++++++++++
compatibility-verifier/test_server_readiness.py | 2 +-
.../server/starter/helix/BaseServerStarter.java | 6 +++
6 files changed, 124 insertions(+), 2 deletions(-)
diff --git a/compatibility-verifier/CompatibilityServerStarter.java
b/compatibility-verifier/CompatibilityServerStarter.java
new file mode 100644
index 00000000000..dd39dc03e29
--- /dev/null
+++ b/compatibility-verifier/CompatibilityServerStarter.java
@@ -0,0 +1,46 @@
+/**
+ * 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.compat;
+
+import java.lang.reflect.InvocationTargetException;
+
+
+/**
+ * Initializes Lucene on the main thread before starting a compatibility
server, including older releases that lack
+ * the startup fix. This stateless entry point must run before any concurrent
Lucene use in the same JVM.
+ */
+public final class CompatibilityServerStarter {
+ private CompatibilityServerStarter() {
+ }
+
+ public static void main(String[] args)
+ throws Throwable {
+ // Lucene 9.12.0 has a class initialization cycle between IndexWriter,
TestSecrets, and ConcurrentMergeScheduler.
+ // Resolve it on one thread before Helix starts loading immutable indexes
and creating realtime indexes in parallel.
+ // https://github.com/apache/lucene/issues/12419
+ Class.forName("org.apache.lucene.index.IndexWriter");
+ try {
+ // Use the distribution's administrator and dependencies, never the
current checkout's Pinot implementation.
+
Class.forName("org.apache.pinot.tools.admin.PinotAdministrator").getMethod("main",
String[].class)
+ .invoke(null, (Object) args);
+ } catch (InvocationTargetException e) {
+ throw e.getCause();
+ }
+ }
+}
diff --git a/compatibility-verifier/README.md b/compatibility-verifier/README.md
index be47643294f..dad3f00def0 100644
--- a/compatibility-verifier/README.md
+++ b/compatibility-verifier/README.md
@@ -56,6 +56,13 @@ OPTIONAL:
### Server readiness and failure diagnostics
+Before starting each server, the verifier initializes Lucene's `IndexWriter`
on the main thread in that server JVM.
+This also covers older releases during initial startup and rollback, avoiding
Lucene 9.12.0's class initialization
+deadlock when Helix loads text indexes and creates realtime text indexes
concurrently. A small bootstrap is compiled
+with `javac --release 11`; each distribution retains its own libraries,
plugins, and launcher settings.
+This workaround remains necessary while compatibility baselines include
releases affected by
+[Lucene issue #12419](https://github.com/apache/lucene/issues/12419).
+
The verifier waits for each server's health endpoint to return success before
running operations after startup,
upgrade, or rollback. HTTP errors do not count as ready. The wait fails if the
process exits or does not become
ready within 600 seconds (configurable with `SERVER_READY_TIMEOUT_SECONDS`).
diff --git a/compatibility-verifier/compCheck.sh
b/compatibility-verifier/compCheck.sh
index 1370863f240..38d63c107dd 100755
--- a/compatibility-verifier/compCheck.sh
+++ b/compatibility-verifier/compCheck.sh
@@ -45,6 +45,7 @@ logCount=1
cmdName=`basename $0`
source "$(dirname "${BASH_SOURCE[0]}")/utils.inc"
source "$(dirname "${BASH_SOURCE[0]}")/server-readiness.inc"
+source "$(dirname "${BASH_SOURCE[0]}")/server-startup.inc"
# Resolve this before changing directory to a distribution's bin directory.
COMPAT_SERVER_LOG4J_CONFIG="$(cd "$(dirname "${BASH_SOURCE[0]}")" &&
pwd)/server-log4j2.xml"
@@ -195,6 +196,7 @@ function startServerWithLogs() {
export LOG4J_CONFIGURATION_FILE="$COMPAT_SERVER_LOG4J_CONFIG"
export LOG_ROOT="$serverLogDir"
export PINOT_COMPONENT="$serviceName"
+ export
CLASSPATH_PREFIX="${COMPAT_SERVER_STARTUP_CLASSES}${CLASSPATH_PREFIX:+:$CLASSPATH_PREFIX}"
if [ -f "$configFile" ]; then
exec "$launcher" StartServer -configFileName "$configFile"
else
@@ -229,7 +231,10 @@ function startService() {
./pinot-admin.sh StartBroker ${configFileArg}
1>${LOG_DIR}/broker.${logCount}.log 2>&1 &
echo $! >${PID_DIR}/broker.pid
elif [ "$serviceName" = "server" ] || [ "$serviceName" = "server2" ]; then
- startServerWithLogs "$serviceName" "$PWD/pinot-admin.sh" "$3"
+ local serverLauncher
+ serverLauncher=$(prepareCompatibilityServerLauncher "$PWD/pinot-admin.sh")
\
+ || abortCompatibilityCheck "Cannot prepare compatibility launcher for
$serviceName"
+ startServerWithLogs "$serviceName" "$serverLauncher" "$3"
elif [ "$serviceName" = "kafka" ]; then
startKafkaService
fi
@@ -545,6 +550,7 @@ oldTargetDir="$workingDir"/oldTargetDir
newTargetDir="$workingDir"/newTargetDir
setupCompatTester
+setupCompatibilityServerStartup "$workingDir" || { echo "Cannot compile
compatibility server bootstrap"; exit 1; }
# check that the default ports are open
if ! checkPortAvailable ${SERVER_ADMIN_PORT} || ! checkPortAvailable
${SERVER_NETTY_PORT} || ! checkPortAvailable ${SERVER_GRPC_PORT} ||
diff --git a/compatibility-verifier/server-startup.inc
b/compatibility-verifier/server-startup.inc
new file mode 100644
index 00000000000..a88b75b8f18
--- /dev/null
+++ b/compatibility-verifier/server-startup.inc
@@ -0,0 +1,57 @@
+#
+# 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.
+#
+
+COMPAT_SERVER_STARTUP_SOURCE="$(cd "$(dirname "${BASH_SOURCE[0]}")" &&
pwd)/CompatibilityServerStarter.java"
+
+# Compile without Pinot dependencies so the bootstrap can run with each tested
distribution's own classes and JDK.
+function setupCompatibilityServerStartup() {
+ local compiler=javac
+ if [ -n "${JAVA_HOME:-}" ]; then
+ compiler="$JAVA_HOME/bin/javac"
+ fi
+ mkdir -p "$1/server-startup" || return 1
+ COMPAT_SERVER_STARTUP_CLASSES="$(cd "$1/server-startup" && pwd)" || return 1
+ "$compiler" --release 11 -d "$COMPAT_SERVER_STARTUP_CLASSES"
"$COMPAT_SERVER_STARTUP_SOURCE"
+}
+
+# Keep the generated script beside the original: appassembler resolves its
libraries, plugins, and configuration
+# relative to the script. Change only the main class, preserving all launcher
JVM options and argument handling.
+function prepareCompatibilityServerLauncher() {
+ local launcher=$1
+ local compatLauncher="${launcher%.sh}-compat.sh"
+ local temporaryLauncher
+ temporaryLauncher=$(mktemp "${compatLauncher}.XXXXXX") || return 1
+ if ! awk '
+ $1 == "org.apache.pinot.tools.admin.PinotAdministrator" {
+ sub(/org\.apache\.pinot\.tools\.admin\.PinotAdministrator/,
"org.apache.pinot.compat.CompatibilityServerStarter")
+ replaced++
+ }
+ { print }
+ END { if (replaced != 1) exit 1 }
+ ' "$launcher" > "$temporaryLauncher"; then
+ echo "Cannot locate exactly one PinotAdministrator main class in
$launcher" >&2
+ rm -f "$temporaryLauncher"
+ return 1
+ fi
+ if ! chmod +x "$temporaryLauncher" || ! mv "$temporaryLauncher"
"$compatLauncher"; then
+ rm -f "$temporaryLauncher"
+ return 1
+ fi
+ echo "$compatLauncher"
+}
diff --git a/compatibility-verifier/test_server_readiness.py
b/compatibility-verifier/test_server_readiness.py
index bf3180df176..d672cf0b7db 100644
--- a/compatibility-verifier/test_server_readiness.py
+++ b/compatibility-verifier/test_server_readiness.py
@@ -205,7 +205,7 @@ function stopServices() {
'exec sleep 60')
script_dir = self.root / "scripts with spaces"
script_dir.mkdir()
- for source in (RUNNER, HELPER, RUNNER.with_name("utils.inc")):
+ for source in (RUNNER, HELPER, RUNNER.with_name("utils.inc"),
RUNNER.with_name("server-startup.inc")):
shutil.copyfile(source, script_dir / source.name)
copied_config = script_dir / "server-log4j2.xml"
shutil.copyfile(HELPER.with_name(copied_config.name), copied_config)
diff --git
a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
index 248d1d96210..5c62d86d38b 100644
---
a/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
+++
b/pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java
@@ -57,6 +57,7 @@ import org.apache.helix.model.builder.HelixConfigScopeBuilder;
import org.apache.helix.participant.statemachine.StateModelFactory;
import org.apache.helix.zookeeper.constant.ZkSystemPropertyKeys;
import org.apache.helix.zookeeper.datamodel.ZNRecord;
+import org.apache.lucene.index.IndexWriter;
import org.apache.pinot.common.Utils;
import org.apache.pinot.common.config.DefaultClusterConfigChangeHandler;
import org.apache.pinot.common.config.TlsConfig;
@@ -663,6 +664,11 @@ public abstract class BaseServerStarter implements
ServiceStartable {
LOGGER.info("Server configs: {}", new
PinotAppConfigs(getConfig()).toJSONString());
long startTimeMs = System.currentTimeMillis();
+ // Initialize Lucene on the startup thread before Helix can load existing
indexes and create realtime indexes
+ // concurrently. Lucene 9.x has a class initialization cycle between
IndexWriter, TestSecrets, and
+ // ConcurrentMergeScheduler: https://github.com/apache/lucene/issues/12419.
+ Class.forName(IndexWriter.class.getName());
+
// Load the index plugins before joining the cluster, so that an invalid
plugin set (for example more than
// IndexService.MAX_INDEX_TYPES index types) fails server startup instead
of every later segment load.
LOGGER.info("Loaded {} index types",
IndexService.getInstance().getAllIndexes().size());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]