This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-4.2
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-4.2 by this push:
new 542fe463496 branch-4.2: [fix](group commit) Honor the master's
schema-change block for INSERTs on followers #70743 (#70975)
542fe463496 is described below
commit 542fe4634964ee911dbc60201f3acb3145c63a26
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Dec 2 11:12:05 2026 +0800
branch-4.2: [fix](group commit) Honor the master's schema-change block for
INSERTs on followers #70743 (#70975)
Cherry-picked from #70743
Co-authored-by: hui lai <[email protected]>
---
.../org/apache/doris/load/GroupCommitManager.java | 9 ++++++--
.../GroupCommitManagerBackendSelectionTest.java | 26 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java
b/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java
index 509c7a7cd0d..64a612eb1bc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/load/GroupCommitManager.java
@@ -31,6 +31,7 @@ import org.apache.doris.common.LoadException;
import org.apache.doris.common.UserException;
import org.apache.doris.common.util.DebugPointUtil;
import org.apache.doris.common.util.SlidingWindowCounter;
+import org.apache.doris.planner.GroupCommitPlanner;
import org.apache.doris.proto.InternalService.PGetWalQueueSizeRequest;
import org.apache.doris.proto.InternalService.PGetWalQueueSizeResponse;
import org.apache.doris.qe.ConnectContext;
@@ -51,9 +52,9 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@@ -62,7 +63,7 @@ public class GroupCommitManager {
private static final Logger LOG =
LogManager.getLogger(GroupCommitManager.class);
- private Set<Long> blockedTableIds = new HashSet<>();
+ private final Set<Long> blockedTableIds = ConcurrentHashMap.newKeySet();
// Selection preferences are part of the bounded cache key.
private final Cache<String, Long> tableToBeMap = CacheBuilder.newBuilder()
@@ -263,6 +264,10 @@ public class GroupCommitManager {
public long selectBackendForGroupCommitInternal(long tableId, String
cluster,
@Nullable BackendSelection.SelectionHint selectionHint)
throws LoadException, DdlException {
+ // A follower planning an INSERT cannot see the master's schema-change
block.
+ if (isBlock(tableId)) {
+ throw new DdlException("insert table " + tableId +
GroupCommitPlanner.SCHEMA_CHANGE);
+ }
// Understanding Group Commit and Backend Selection Logic
//
// Group commit is a server-side technique used for batching data
imports.
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/load/GroupCommitManagerBackendSelectionTest.java
b/fe/fe-core/src/test/java/org/apache/doris/load/GroupCommitManagerBackendSelectionTest.java
index db26b5ddbfd..95d12b26270 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/load/GroupCommitManagerBackendSelectionTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/load/GroupCommitManagerBackendSelectionTest.java
@@ -22,6 +22,7 @@ import org.apache.doris.catalog.OlapTable;
import org.apache.doris.cloud.system.CloudSystemInfoService;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.Config;
+import org.apache.doris.common.DdlException;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.resource.BackendSelection;
@@ -68,6 +69,31 @@ public class GroupCommitManagerBackendSelectionTest {
Assert.assertEquals(0, policy.getLoadSelectionHintCalls);
}
+ @Test
+ public void testSchemaChangeBlocksSelectionEvenForCachedBackend() throws
Exception {
+ Config.cloud_unique_id = "";
+ Config.deploy_mode = "";
+ long tableId = 10001L;
+ GroupCommitManager manager = new GroupCommitManager();
+ Env env = mockEnv(tableId);
+ SystemInfoService systemInfoService = mockSystemInfoService();
+
+ try (MockedStatic<Env> mockedEnv = Mockito.mockStatic(Env.class)) {
+ mockedEnv.when(Env::getCurrentEnv).thenReturn(env);
+
mockedEnv.when(Env::getCurrentSystemInfo).thenReturn(systemInfoService);
+ long backendId =
manager.selectBackendForGroupCommitInternal(tableId, "", null);
+
+ manager.blockTable(tableId);
+ DdlException error = Assertions.assertThrows(DdlException.class,
+ () -> manager.selectBackendForGroupCommitInternal(tableId,
"", null));
+ Assertions.assertTrue(error.getMessage().contains(
+ "insert table " + tableId + " is blocked on schema
change"));
+
+ manager.unblockTable(tableId);
+ Assertions.assertEquals(backendId,
manager.selectBackendForGroupCommitInternal(tableId, "", null));
+ }
+ }
+
@Test
public void testEffectiveLoadSelectionCacheUsesSelectionKey() throws
Exception {
Config.cloud_unique_id = "";
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]