This is an automated email from the ASF dual-hosted git repository.
tanxinyu 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 142f3c81268 Remove infinite retry logic for replica inconsistency to
avoid potential problems (#12028)
142f3c81268 is described below
commit 142f3c81268dad6def382c38c193adb89a9c02de
Author: Potato <[email protected]>
AuthorDate: Mon Feb 5 17:12:51 2024 +0800
Remove infinite retry logic for replica inconsistency to avoid potential
problems (#12028)
Signed-off-by: OneSizeFitQuorum <[email protected]>
---
.../statemachine/dataregion/DataRegionStateMachine.java | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/dataregion/DataRegionStateMachine.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/dataregion/DataRegionStateMachine.java
index f916d480fdc..38a973d554d 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/dataregion/DataRegionStateMachine.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/consensus/statemachine/dataregion/DataRegionStateMachine.java
@@ -65,6 +65,8 @@ public class DataRegionStateMachine extends BaseStateMachine {
protected DataRegion region;
+ private static final int MAX_WRITE_RETRY_TIMES = 5;
+
private static final long WRITE_RETRY_WAIT_TIME_IN_MS = 1000;
public DataRegionStateMachine(DataRegion region) {
@@ -241,18 +243,18 @@ public class DataRegionStateMachine extends
BaseStateMachine {
protected TSStatus write(PlanNode planNode) {
// To ensure the Data inconsistency between multiple replications, we add
retry in write
// operation.
- TSStatus result;
+ TSStatus result = null;
int retryTime = 0;
- while (true) {
+ while (retryTime < MAX_WRITE_RETRY_TIMES) {
result = planNode.accept(new DataExecutionVisitor(), region);
if (needRetry(result.getCode())) {
retryTime++;
logger.debug(
"write operation failed because {}, retryTime: {}.",
result.getCode(), retryTime);
- if (retryTime % 5 == 0) {
+ if (retryTime == MAX_WRITE_RETRY_TIMES) {
logger.error(
"write operation still failed after {} retry times, because {}.",
- retryTime,
+ MAX_WRITE_RETRY_TIMES,
result.getCode());
}
try {