You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2024/03/05 02:29:43 UTC
(iotdb) 12/22: Remove infinite retry logic for replica inconsistency to avoid potential problems (#12028)
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch rc/1.3.1
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit fac1f6899ca0b5eca3d041d2658d21f3b474734b
Author: Potato <ta...@apache.org>
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 <ta...@apache.org>
---
.../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 {