Skip to content

Commit f47f8a8

Browse files
CaideyipiJackieTien97
authored andcommitted
Fixed the bug that the first query may be rejected when read only in table model for simple consensus
(cherry picked from commit 95648df)
1 parent 64ec540 commit f47f8a8

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ public TSStatus write(ConsensusGroupId groupId, IConsensusRequest request)
324324
}
325325

326326
// current Peer is group leader and in ReadOnly State
327+
// We only judge dataRegions here, because schema write when readOnly is handled at
328+
// RegionWriteExecutor
327329
if (isLeader(groupId) && Utils.rejectWrite(consensusGroupType)) {
328330
try {
329331
forceStepDownLeader(raftGroup);

iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/simple/SimpleConsensus.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public TSStatus write(ConsensusGroupId groupId, IConsensusRequest request)
119119
SimpleConsensusServerImpl impl =
120120
Optional.ofNullable(stateMachineMap.get(groupId))
121121
.orElseThrow(() -> new ConsensusGroupNotExistException(groupId));
122-
if (impl.isReadOnly()) {
122+
// Schema Write when readOnly is handled at RegionWriteExecutor
123+
if (impl.isReadOnly() && groupId instanceof DataRegionId) {
123124
return StatusUtils.getStatus(TSStatusCode.SYSTEM_READ_ONLY);
124125
} else {
125126
TSStatus status;

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/executor/RegionWriteExecutor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ private class WritePlanNodeExecutionVisitor
187187
public RegionExecutionResult visitPlan(
188188
final PlanNode node, final WritePlanNodeExecutionContext context) {
189189

190+
// All the plans are rejected here when readOnly except for insertion, which is rejected in
191+
// the stateMachine's "write" interface
190192
if (CommonDescriptor.getInstance().getConfig().isReadOnly() && !isForceExecutedPlan(node)) {
191193
return RegionExecutionResult.create(
192194
false,

0 commit comments

Comments
 (0)