Skip to content

Commit

Permalink
[ISSUE #162] fix sync stopped when upgrade 0.2.6 from 0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
cserwen authored Jul 4, 2022
1 parent 5fb963e commit ba6424f
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,11 @@ private void sendBatchAppendEntryRequest() throws Exception {
switch (responseCode) {
case SUCCESS:
batchPendingMap.remove(x.getIndex());
updatePeerWaterMark(x.getTerm(), peerId, x.getIndex() + x.getCount() - 1);
if (x.getCount() == 0) {
updatePeerWaterMark(x.getTerm(), peerId, x.getIndex());
} else {
updatePeerWaterMark(x.getTerm(), peerId, x.getIndex() + x.getCount() - 1);
}
break;
case INCONSISTENT_STATE:
logger.info("[Push-{}]Get INCONSISTENT_STATE when batch push index={} term={}", peerId, x.getIndex(), x.getTerm());
Expand Down Expand Up @@ -629,10 +633,10 @@ private void doBatchAppendInner(long index) throws Exception {

private void doCheckBatchAppendResponse() throws Exception {
long peerWaterMark = getPeerWaterMark(term, peerId);
Pair pair = batchPendingMap.get(peerWaterMark + 1);
if (pair != null && System.currentTimeMillis() - (long) pair.getKey() > dLedgerConfig.getMaxPushTimeOutMs()) {
Pair<Long, Integer> pair = batchPendingMap.get(peerWaterMark + 1);
if (pair != null && System.currentTimeMillis() - pair.getKey() > dLedgerConfig.getMaxPushTimeOutMs()) {
long firstIndex = peerWaterMark + 1;
long lastIndex = firstIndex + (int) pair.getValue() - 1;
long lastIndex = firstIndex + pair.getValue() - 1;
logger.warn("[Push-{}]Retry to push entry from {} to {}", peerId, firstIndex, lastIndex);
batchAppendEntryRequest.clear();
for (long i = firstIndex; i <= lastIndex; i++) {
Expand Down

0 comments on commit ba6424f

Please sign in to comment.