This is an automated email from the ASF dual-hosted git repository.
suxiaogang223 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5b9d41476bb [improvement](iceberg) Make the shared FE worker pool size
configurable (#70793)
5b9d41476bb is described below
commit 5b9d41476bbfbd02608be34ee97265a32c2df9cd
Author: Socrates <[email protected]>
AuthorDate: Mon Nov 23 17:40:40 2026 +0800
[improvement](iceberg) Make the shared FE worker pool size configurable
(#70793)
### Background
The Iceberg connector uses the SDK's shared worker pool for parallel
manifest planning and manifest writes. All Iceberg catalogs on an FE,
including Iceberg siblings of Hive catalogs, use the same plugin and
pool. The SDK sizes this pool from a JVM property or environment
variable, defaulting to max(2, available processors).
### What problem does this PR solve?
Issue Number: None
Related PR: None
PR Type: Enhancement
Problem Summary:
Operators need a deployment-level way to set the shared Iceberg worker
budget through the connector configuration. Master already shares the
SDK pool across catalogs, but iceberg.conf does not expose its size. Add
a startup-only setting and apply it before the first connector can
initialize the SDK pool, covering both scan planning and SDK-internal
manifest writes.
### Details
- **Before and after:** Previously only the SDK JVM property/environment
setting controlled the shared pool. Operators can now configure its
total worker count in iceberg.conf; no per-catalog executor is
introduced.
- **Configs and defaults:** Add optional `worker_thread_pool_size` to
the Iceberg plugin's `iceberg.conf`. It must be a positive integer and
requires an FE restart on each node. When unset or blank, preserve
`iceberg.worker.num-threads` / `ICEBERG_WORKER_NUM_THREADS` and the SDK
default of max(2, available processors). An explicit plugin setting
takes precedence over those SDK settings. The SDK queue and separate
engine metadata, deletion, authentication-refresh and
cancellation-cleanup pools are unchanged.
- **Impact on existing users:** Untouched deployments retain their
existing worker count. Explicit settings apply across standalone Iceberg
catalogs and Hive catalog Iceberg siblings. Invalid values fail
connector initialization with the setting name. An already initialized
SDK pool with a different size is rejected rather than silently ignoring
the configured limit.
- **Behavior change:** An explicit plugin setting changes the shared SDK
worker count for manifest planning and manifest writes. SDK ownership,
catalog authentication, worker classloader pinning and scan
cancellation/cleanup are preserved.
### Testing
Local checks passed:
- `cd fe && mvn -B -pl :fe-connector-iceberg checkstyle:check
-Dmaven.build.cache.enabled=false` — zero Checkstyle violations,
including test sources.
- `bash build-support/check-fe-connector-imports.sh`
- `bash build-support/check-fe-core-metadata-funnel.sh`
- `git diff --cached --check`
Added JUnit coverage for positive/invalid/blank configuration,
concurrent initialization across catalog contexts, SDK setting
precedence, shared-pool survival after scan cancellation/close, worker
classloader pinning and premature SDK initialization. These tests have
not been executed locally. Compilation and unit/regression tests were
not run; local validation was limited to style and static checks.
### Release note
Iceberg's shared FE worker pool can be sized with the optional positive
`worker_thread_pool_size` setting in the plugin's `iceberg.conf`. The
setting applies to all Iceberg catalogs on that FE and requires an FE
restart. Leaving it unset preserves the existing SDK configuration and
defaults.
### Check List (For Author)
- Behavior changed: Yes (see Details).
- Does this need documentation: No additional documentation; usage,
defaults, precedence and restart requirements are documented in the
shipped iceberg.conf.template.
- Pre-submission status: Partially verified: local style/static checks
passed; compilation and unit/regression tests have not been run.
### AI Disclosure
- Tool: Codex (GPT-6).
- Generated: Code, tests and this description.
- Human review: Pending.
---
.../doris/connector/iceberg/IcebergConf.java | 21 +++
.../doris/connector/iceberg/IcebergConnector.java | 2 +
.../doris/connector/iceberg/IcebergWorkerPool.java | 55 ++++++
.../src/main/resources/iceberg.conf.template | 8 +
.../iceberg/IcebergConnectorConfTest.java | 17 ++
.../connector/iceberg/IcebergWorkerPoolTest.java | 188 +++++++++++++++++++++
6 files changed, 291 insertions(+)
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConf.java
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConf.java
index 79c73f229b6..8b425f0c675 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConf.java
+++
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConf.java
@@ -37,6 +37,7 @@ public final class IcebergConf {
public static final String CONF_DRIVERS_DIR = "drivers_dir";
public static final String CONF_METASTORE_CLIENT_TIMEOUT_SECOND =
"metastore_client_timeout_second";
public static final String CONF_ENABLE_ENCRYPTION_READ =
"enable_encryption_read";
+ public static final String CONF_WORKER_THREAD_POOL_SIZE =
"worker_thread_pool_size";
/** The fe.conf name of {@link #CONF_DRIVERS_DIR}, forwarded through the
engine environment. */
public static final String ENV_JDBC_DRIVERS_DIR = "jdbc_drivers_dir";
@@ -51,6 +52,26 @@ public final class IcebergConf {
private IcebergConf() {
}
+ /** Null preserves the SDK's startup setting; a positive override bounds
the FE-wide shared pool. */
+ public static Integer workerThreadPoolSize(ConnectorContext context) {
+ String value = ConnectorConf.get(context,
CONF_WORKER_THREAD_POOL_SIZE, null, null);
+ if (value == null) {
+ return null;
+ }
+ int size;
+ try {
+ size = Integer.parseInt(value.trim());
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException("iceberg.conf " +
CONF_WORKER_THREAD_POOL_SIZE
+ + " must be a positive integer: " + value, e);
+ }
+ if (size <= 0) {
+ throw new IllegalArgumentException("iceberg.conf " +
CONF_WORKER_THREAD_POOL_SIZE
+ + " must be a positive integer: " + value);
+ }
+ return size;
+ }
+
/** Operator intent only: the read contract independently requires
verified backend capabilities. */
public static boolean encryptionReadEnabled(ConnectorContext context) {
return context != null && Boolean.parseBoolean(
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnector.java
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnector.java
index 5ee253226e0..8b1074e1fd7 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnector.java
+++
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergConnector.java
@@ -251,6 +251,8 @@ public class IcebergConnector implements Connector {
private volatile boolean pluginAuthComputed;
public IcebergConnector(Map<String, String> properties, ConnectorContext
context) {
+ // Configure the SDK before any catalog/scan/commit can initialize its
static worker pool.
+ IcebergWorkerPool.initialize(context);
this.properties = Collections.unmodifiableMap(properties);
// Both before isUserSessionEnabled(), which the cache fields below
gate on.
this.catalogProps = IcebergCatalogProperties.of(this.properties);
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergWorkerPool.java
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergWorkerPool.java
new file mode 100644
index 00000000000..59256457333
--- /dev/null
+++
b/fe/fe-connector/fe-connector-iceberg/src/main/java/org/apache/doris/connector/iceberg/IcebergWorkerPool.java
@@ -0,0 +1,55 @@
+// 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.doris.connector.iceberg;
+
+import org.apache.doris.connector.spi.ConnectorContext;
+
+import org.apache.iceberg.SystemConfigs;
+import org.apache.iceberg.util.ThreadPools;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+/** Initializes the SDK-owned worker pool once for all Iceberg catalogs in
this FE. */
+final class IcebergWorkerPool {
+ private static final Logger LOG =
LogManager.getLogger(IcebergWorkerPool.class);
+ // Guarded by the class monitor. Catalog creation may race, but the plugin
configuration is FE-wide.
+ private static boolean initialized;
+
+ private IcebergWorkerPool() {
+ }
+
+ static synchronized void initialize(ConnectorContext context) {
+ if (initialized) {
+ return;
+ }
+ Integer configuredSize = IcebergConf.workerThreadPoolSize(context);
+ if (configuredSize != null) {
+ // Keep the SDK's pool rather than adding a Doris-only planning
pool: SDK-internal manifest
+ // writes and scans must use the same limit. SystemConfigs caches
this value on first access.
+
System.setProperty(SystemConfigs.WORKER_THREAD_POOL_SIZE.propertyKey(),
configuredSize.toString());
+ }
+ int actualSize = ThreadPools.WORKER_THREAD_POOL_SIZE;
+ if (configuredSize != null && actualSize != configuredSize) {
+ throw new IllegalStateException("Iceberg worker pool was
initialized with " + actualSize
+ + " threads before iceberg.conf " +
IcebergConf.CONF_WORKER_THREAD_POOL_SIZE
+ + "=" + configuredSize + " was applied; restart the FE to
apply the limit");
+ }
+ LOG.info("Iceberg shared worker pool size: {} threads across all
catalogs", actualSize);
+ initialized = true;
+ }
+}
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/main/resources/iceberg.conf.template
b/fe/fe-connector/fe-connector-iceberg/src/main/resources/iceberg.conf.template
index 1fe0309ff9b..88f36ce9e10 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/main/resources/iceberg.conf.template
+++
b/fe/fe-connector/fe-connector-iceberg/src/main/resources/iceberg.conf.template
@@ -22,6 +22,14 @@
# whose default is 10.
# metastore_client_timeout_second=10
+# Maximum worker threads shared by ALL Iceberg catalogs in this FE, including
HMS Iceberg tables.
+# Applies to SDK manifest planning and manifest writes. This is not a
per-catalog or per-query setting.
+# Must be a positive integer; excess work queues in the SDK pool. Requires an
FE restart.
+# When unset, retains the SDK's iceberg.worker.num-threads /
ICEBERG_WORKER_NUM_THREADS setting,
+# whose default is max(2, available processors). This setting takes precedence
over both.
+# Does not limit separate engine metadata schedulers, SDK deletion/auth pools
or cancellation cleanup.
+# worker_thread_pool_size=16
+
# Encrypted-read admission intent only; default false, with no fe.conf
fallback.
# Enabling this does not enable encrypted writes or bypass missing backend
read capabilities.
# Encrypted scan execution remains unavailable until explicit backend
negotiation and readers exist.
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergConnectorConfTest.java
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergConnectorConfTest.java
index 2c8ddac01fe..9084d0cedd8 100644
---
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergConnectorConfTest.java
+++
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergConnectorConfTest.java
@@ -37,6 +37,23 @@ import java.util.Map;
*/
public class IcebergConnectorConfTest {
+ @Test
+ public void workerPoolSizeUsesOnlyPositivePluginConfiguration() {
+
Assertions.assertNull(IcebergConf.workerThreadPoolSize(context(Map.of(),
Map.of())));
+ Assertions.assertNull(IcebergConf.workerThreadPoolSize(
+ context(Map.of(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE, " "),
Map.of())));
+ Assertions.assertNull(IcebergConf.workerThreadPoolSize(
+ context(Map.of(),
Map.of(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE, "8"))));
+ Assertions.assertEquals(1, IcebergConf.workerThreadPoolSize(
+ context(Map.of(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE, " 1
"), Map.of())));
+ for (String invalid : new String[] {"0", "-1", "many", "2147483648"}) {
+ IllegalArgumentException error =
Assertions.assertThrows(IllegalArgumentException.class,
+ () -> IcebergConf.workerThreadPoolSize(
+
context(Map.of(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE, invalid), Map.of())));
+
Assertions.assertTrue(error.getMessage().contains(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE));
+ }
+ }
+
@Test
public void encryptionReadIsDefaultOffAndUsesOnlyPluginConfiguration() {
Assertions.assertFalse(IcebergConf.encryptionReadEnabled(null));
diff --git
a/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergWorkerPoolTest.java
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergWorkerPoolTest.java
new file mode 100644
index 00000000000..28d43324b3b
--- /dev/null
+++
b/fe/fe-connector/fe-connector-iceberg/src/test/java/org/apache/doris/connector/iceberg/IcebergWorkerPoolTest.java
@@ -0,0 +1,188 @@
+// 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.doris.connector.iceberg;
+
+import org.apache.doris.connector.spi.ConnectorContext;
+import org.apache.doris.connector.spi.scan.ConnectorScanContext;
+
+import org.apache.iceberg.util.ThreadPools;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.ResourceLock;
+import org.junit.jupiter.api.parallel.Resources;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
+/** Isolated SDK statics make startup-order tests independent of other tests'
Iceberg use. */
+@ResourceLock(Resources.SYSTEM_PROPERTIES)
+public class IcebergWorkerPoolTest {
+ private static final String SDK_SIZE_PROPERTY =
"iceberg.worker.num-threads";
+ private String previousSize;
+
+ @BeforeEach
+ public void saveProperty() {
+ previousSize = System.getProperty(SDK_SIZE_PROPERTY);
+ // The scope lifecycle assertion uses parent-loaded classes. Keep
their SDK statics on the
+ // original startup value before changing the property for the
isolated SDK copies below.
+ ThreadPools.getWorkerPool();
+ }
+
+ @AfterEach
+ public void restoreProperty() {
+ if (previousSize == null) {
+ System.clearProperty(SDK_SIZE_PROPERTY);
+ } else {
+ System.setProperty(SDK_SIZE_PROPERTY, previousSize);
+ }
+ }
+
+ @Test
+ public void racingCatalogsShareTheConfiguredSdkPool() throws Exception {
+ System.setProperty(SDK_SIZE_PROPERTY, "8");
+ ExecutorService callers = Executors.newFixedThreadPool(4);
+ try (URLClassLoader loader = isolatedLoader()) {
+ CountDownLatch start = new CountDownLatch(1);
+ List<Future<ExecutorService>> pools = new ArrayList<>();
+ for (int i = 0; i < 4; i++) {
+ final int catalogId = i;
+ pools.add(callers.submit(() -> {
+ start.await();
+ initialize(loader, context(catalogId,
Map.of(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE, "2")));
+ return workerPool(loader);
+ }));
+ }
+ start.countDown();
+ ExecutorService shared = pools.get(0).get(10, TimeUnit.SECONDS);
+ try {
+ for (Future<ExecutorService> pool : pools) {
+ Assertions.assertSame(shared, pool.get(10,
TimeUnit.SECONDS));
+ }
+ Assertions.assertEquals(2, workerPoolSize(loader));
+ Assertions.assertEquals("2",
System.getProperty(SDK_SIZE_PROPERTY));
+ // Pinning must still reach every worker at the configured
size, including a size below CPUs.
+
Assertions.assertTrue(IcebergConnector.pinPoolThreadsToClassLoader(shared, 2,
loader, 5));
+ Assertions.assertSame(loader,
+ shared.submit(() ->
Thread.currentThread().getContextClassLoader()).get(5, TimeUnit.SECONDS));
+ ConnectorScanContext scanContext = new ConnectorScanContext();
+ try (IcebergScanPlanningScope scope = new
IcebergScanPlanningScope(scanContext, shared)) {
+ Assertions.assertEquals(42, scope.submit(() -> 42).get(5,
TimeUnit.SECONDS));
+ scanContext.cancel();
+ }
+ Assertions.assertFalse(shared.isShutdown(), "a scan must not
own the FE-wide pool");
+ Assertions.assertEquals(42, shared.submit(() -> 42).get(5,
TimeUnit.SECONDS));
+ } finally {
+ shared.shutdownNow();
+ }
+ } finally {
+ callers.shutdownNow();
+ }
+ }
+
+ @Test
+ public void unsetPluginConfigurationPreservesSdkStartupSetting() throws
Exception {
+ System.setProperty(SDK_SIZE_PROPERTY, "3");
+ try (URLClassLoader loader = isolatedLoader()) {
+ initialize(loader, context(1, Map.of()));
+ Assertions.assertEquals(3, workerPoolSize(loader));
+ Assertions.assertEquals("3",
System.getProperty(SDK_SIZE_PROPERTY));
+ }
+ }
+
+ @Test
+ public void alreadyInitializedSdkCannotSilentlyIgnoreTheLimit() throws
Exception {
+ System.setProperty(SDK_SIZE_PROPERTY, "3");
+ try (URLClassLoader loader = isolatedLoader()) {
+ Assertions.assertEquals(3, workerPoolSize(loader));
+ InvocationTargetException error =
Assertions.assertThrows(InvocationTargetException.class,
+ () -> initialize(loader, context(1,
Map.of(IcebergConf.CONF_WORKER_THREAD_POOL_SIZE, "2"))));
+ Assertions.assertInstanceOf(IllegalStateException.class,
error.getCause());
+
Assertions.assertTrue(error.getCause().getMessage().contains("before
iceberg.conf"));
+ Assertions.assertEquals(3, workerPoolSize(loader));
+ }
+ }
+
+ private static void initialize(ClassLoader loader, ConnectorContext
context) throws Exception {
+ Class<?> owner = loader.loadClass(IcebergWorkerPool.class.getName());
+ Method initialize = owner.getDeclaredMethod("initialize",
ConnectorContext.class);
+ initialize.setAccessible(true);
+ initialize.invoke(null, context);
+ }
+
+ private static ExecutorService workerPool(ClassLoader loader) throws
Exception {
+ return (ExecutorService)
loader.loadClass(ThreadPools.class.getName()).getMethod("getWorkerPool").invoke(null);
+ }
+
+ private static int workerPoolSize(ClassLoader loader) throws Exception {
+ return
loader.loadClass(ThreadPools.class.getName()).getField("WORKER_THREAD_POOL_SIZE").getInt(null);
+ }
+
+ private static URLClassLoader isolatedLoader() {
+ URL[] urls =
{IcebergWorkerPool.class.getProtectionDomain().getCodeSource().getLocation(),
+
ThreadPools.class.getProtectionDomain().getCodeSource().getLocation()};
+ return new URLClassLoader(urls,
IcebergWorkerPoolTest.class.getClassLoader()) {
+ @Override
+ protected Class<?> loadClass(String name, boolean resolve) throws
ClassNotFoundException {
+ synchronized (getClassLoadingLock(name)) {
+ if (name.equals(IcebergWorkerPool.class.getName())
+ ||
name.startsWith("org.apache.iceberg.SystemConfigs")
+ || name.startsWith(ThreadPools.class.getName())) {
+ Class<?> loaded = findLoadedClass(name);
+ Class<?> type = loaded == null ? findClass(name) :
loaded;
+ if (resolve) {
+ resolveClass(type);
+ }
+ return type;
+ }
+ return super.loadClass(name, resolve);
+ }
+ }
+ };
+ }
+
+ private static ConnectorContext context(long catalogId, Map<String,
String> config) {
+ return new ConnectorContext() {
+ @Override
+ public String getCatalogName() {
+ return "catalog_" + catalogId;
+ }
+
+ @Override
+ public long getCatalogId() {
+ return catalogId;
+ }
+
+ @Override
+ public Map<String, String> getConnectorConfig() {
+ return config;
+ }
+ };
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]