From 85a6cc1c8ee97fa6dade53971bc3ab5594707c5a Mon Sep 17 00:00:00 2001 From: wqliang Date: Wed, 16 Oct 2019 10:32:28 +0800 Subject: [PATCH] fix ha sync transfer timeout --- .../main/java/org/apache/rocketmq/store/ha/HAService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java index 84fb4217..2d02d431 100644 --- a/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java +++ b/store/src/main/java/org/apache/rocketmq/store/ha/HAService.java @@ -280,9 +280,14 @@ public class HAService { if (!this.requestsRead.isEmpty()) { for (CommitLog.GroupCommitRequest req : this.requestsRead) { boolean transferOK = HAService.this.push2SlaveMaxOffset.get() >= req.getNextOffset(); - for (int i = 0; !transferOK && i < 5; i++) { + long waitUntillWhen = HAService.this.defaultMessageStore.getSystemClock().now() + + HAService.this.defaultMessageStore.getMessageStoreConfig().getSyncFlushTimeout(); + while (HAService.this.defaultMessageStore.getSystemClock().now() < waitUntillWhen) { this.notifyTransferObject.waitForRunning(1000); transferOK = HAService.this.push2SlaveMaxOffset.get() >= req.getNextOffset(); + if (transferOK) { + break; + } } if (!transferOK) { -- GitLab