This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 95648dfa936 Fixed the bug that the first query may be rejected when
read only in table model for simple consensus
95648dfa936 is described below
commit 95648dfa936d5b17ad51b7a8d791baa3119a9dd7
Author: Caideyipi <[email protected]>
AuthorDate: Thu May 22 16:33:50 2025 +0800
Fixed the bug that the first query may be rejected when read only in table
model for simple consensus
---
.../src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java | 2 ++
.../main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java | 3 ++-
.../iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java | 2 ++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
index 7a7bdc2f9c5..ff16434df14 100644
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
+++
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java
@@ -324,6 +324,8 @@ class RatisConsensus implements IConsensus {
}
// current Peer is group leader and in ReadOnly State
+ // We only judge dataRegions here, because schema write when readOnly is
handled at
+ // RegionWriteExecutor
if (isLeader(groupId) && Utils.rejectWrite(consensusGroupType)) {
try {
forceStepDownLeader(raftGroup);
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
index 5800e76b008..f7fcba1a597 100644
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
+++
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java
@@ -119,7 +119,8 @@ class SimpleConsensus implements IConsensus {
SimpleConsensusServerImpl impl =
Optional.ofNullable(stateMachineMap.get(groupId))
.orElseThrow(() -> new ConsensusGroupNotExistException(groupId));
- if (impl.isReadOnly()) {
+ // Schema Write when readOnly is handled at RegionWriteExecutor
+ if (impl.isReadOnly() && groupId instanceof DataRegionId) {
return StatusUtils.getStatus(TSStatusCode.SYSTEM_READ_ONLY);
} else {
TSStatus status;
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
index 46a7cdbf7d0..60dda197578 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java
@@ -187,6 +187,8 @@ public class RegionWriteExecutor {
public RegionExecutionResult visitPlan(
final PlanNode node, final WritePlanNodeExecutionContext context) {
+ // All the plans are rejected here when readOnly except for insertion,
which is rejected in
+ // the stateMachine's "write" interface
if (CommonDescriptor.getInstance().getConfig().isReadOnly() &&
!isForceExecutedPlan(node)) {
return RegionExecutionResult.create(
false,