This is an automated email from the ASF dual-hosted git repository.
liaoxin01 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 f1e6c157ea1 [fix](group commit) Honor the master's schema-change block
for INSERTs on followers (#70743)
f1e6c157ea1 is described below
commit f1e6c157ea1de06ce32317a5c4b7750334b1d952
Author: hui lai <[email protected]>
AuthorDate: Wed Nov 25 09:38:09 2026 +0800
[fix](group commit) Honor the master's schema-change block for INSERTs on
followers (#70743)
### Problem
During schema change, the master temporarily blocks Group Commit writes
to the table while it waits for outstanding WALs to drain. A follower
planning an INSERT checks its own in-memory block list, which does not
contain the master's marker. It then asks the master for a BE ID, and
the master could return one without checking the block.
### Impact
As a result, an INSERT sent to a follower could join an existing batch
while the same INSERT sent to the master would be rejected. New writes
during that window could delay WAL drainage.
### Fix
Check the master's block list before selecting a BE or returning a
cached BE ID. If the table is blocked, the existing RPC returns the
schema-change error to the follower.
---
.../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 0da766fadda..841117a73d5 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()
@@ -265,6 +266,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 8979a3b7660..86697e22ade 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 {
Assertions.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]