Skip to content

Commit

Permalink
Remove infinite retry logic for replica inconsistency to avoid potent…
Browse files Browse the repository at this point in the history
…ial problems (#12028)

Signed-off-by: OneSizeFitQuorum <[email protected]>
  • Loading branch information
OneSizeFitsQuorum authored Feb 5, 2024
1 parent 1a10621 commit 142f3c8
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -241,18 +243,18 @@ public TSStatus write(IConsensusRequest request) {
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 {
Expand Down

0 comments on commit 142f3c8

Please sign in to comment.