@@ -598,7 +598,11 @@ private void sendBatchAppendEntryRequest() throws Exception {
598598 switch (responseCode ) {
599599 case SUCCESS :
600600 batchPendingMap .remove (x .getIndex ());
601- updatePeerWaterMark (x .getTerm (), peerId , x .getIndex () + x .getCount () - 1 );
601+ if (x .getCount () == 0 ) {
602+ updatePeerWaterMark (x .getTerm (), peerId , x .getIndex ());
603+ } else {
604+ updatePeerWaterMark (x .getTerm (), peerId , x .getIndex () + x .getCount () - 1 );
605+ }
602606 break ;
603607 case INCONSISTENT_STATE :
604608 logger .info ("[Push-{}]Get INCONSISTENT_STATE when batch push index={} term={}" , peerId , x .getIndex (), x .getTerm ());
@@ -629,10 +633,10 @@ private void doBatchAppendInner(long index) throws Exception {
629633
630634 private void doCheckBatchAppendResponse () throws Exception {
631635 long peerWaterMark = getPeerWaterMark (term , peerId );
632- Pair pair = batchPendingMap .get (peerWaterMark + 1 );
633- if (pair != null && System .currentTimeMillis () - ( long ) pair .getKey () > dLedgerConfig .getMaxPushTimeOutMs ()) {
636+ Pair < Long , Integer > pair = batchPendingMap .get (peerWaterMark + 1 );
637+ if (pair != null && System .currentTimeMillis () - pair .getKey () > dLedgerConfig .getMaxPushTimeOutMs ()) {
634638 long firstIndex = peerWaterMark + 1 ;
635- long lastIndex = firstIndex + ( int ) pair .getValue () - 1 ;
639+ long lastIndex = firstIndex + pair .getValue () - 1 ;
636640 logger .warn ("[Push-{}]Retry to push entry from {} to {}" , peerId , firstIndex , lastIndex );
637641 batchAppendEntryRequest .clear ();
638642 for (long i = firstIndex ; i <= lastIndex ; i ++) {
0 commit comments