From 291d85bee784fc278011dacf5c2ba57ef87bc0c3 Mon Sep 17 00:00:00 2001 From: Yehonatan Buchnik Date: Thu, 30 Jun 2022 19:31:28 +0300 Subject: [PATCH 1/2] Fix a bug when reaching the maximal size of preprepare --- bftengine/src/bftengine/ReplicaImp.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bftengine/src/bftengine/ReplicaImp.cpp b/bftengine/src/bftengine/ReplicaImp.cpp index f77cf82e13..3792824f81 100644 --- a/bftengine/src/bftengine/ReplicaImp.cpp +++ b/bftengine/src/bftengine/ReplicaImp.cpp @@ -719,10 +719,14 @@ ClientRequestMsg *ReplicaImp::addRequestToPrePrepareMessage(ClientRequestMsg *&n nextRequest->clientProxyId(), nextRequest->requestSeqNum(), nextRequest->getCid()); metric_primary_batching_duration_.finishMeasurement(nextRequest->getCid()); } - } else if (nextRequest->size() > maxStorageForRequests) { // The message is too big + } else { // The message is too big LOG_WARN(GL, - "Request was dropped because it exceeds maximum allowed size" << KVLOG( - prePrepareMsg.seqNumber(), nextRequest->senderId(), nextRequest->size(), maxStorageForRequests)); + "Request was dropped because it exceeds maximum allowed size" + << KVLOG(prePrepareMsg.seqNumber(), + nextRequest->senderId(), + nextRequest->size(), + prePrepareMsg.remainingSizeForRequests())); + return nullptr; // To break the outside loop that } primaryCombinedReqSize -= nextRequest->size(); requestsQueueOfPrimary.pop(); From fb675160daf91dc1f411d1d5877e65fdf3890b6f Mon Sep 17 00:00:00 2001 From: Yehonatan Buchnik Date: Sun, 3 Jul 2022 11:11:39 +0300 Subject: [PATCH 2/2] Fix a bug --- bftengine/src/bftengine/ReplicaImp.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/bftengine/src/bftengine/ReplicaImp.cpp b/bftengine/src/bftengine/ReplicaImp.cpp index 3792824f81..d823f75596 100644 --- a/bftengine/src/bftengine/ReplicaImp.cpp +++ b/bftengine/src/bftengine/ReplicaImp.cpp @@ -711,7 +711,8 @@ PrePrepareMsg *ReplicaImp::createPrePrepareMessage() { ClientRequestMsg *ReplicaImp::addRequestToPrePrepareMessage(ClientRequestMsg *&nextRequest, PrePrepareMsg &prePrepareMsg, uint32_t maxStorageForRequests) { - if (nextRequest->size() <= prePrepareMsg.remainingSizeForRequests()) { + uint64_t remaining_size = prePrepareMsg.remainingSizeForRequests(); + if (nextRequest->size() <= remaining_size) { SCOPED_MDC_CID(nextRequest->getCid()); if (clientsManager->canBecomePending(nextRequest->clientProxyId(), nextRequest->requestSeqNum())) { prePrepareMsg.addRequest(nextRequest->body(), nextRequest->size()); @@ -719,14 +720,16 @@ ClientRequestMsg *ReplicaImp::addRequestToPrePrepareMessage(ClientRequestMsg *&n nextRequest->clientProxyId(), nextRequest->requestSeqNum(), nextRequest->getCid()); metric_primary_batching_duration_.finishMeasurement(nextRequest->getCid()); } - } else { // The message is too big + } else if (nextRequest->size() > + maxStorageForRequests) { // The message will never be able to get into a prepreapre message LOG_WARN(GL, - "Request was dropped because it exceeds maximum allowed size" - << KVLOG(prePrepareMsg.seqNumber(), - nextRequest->senderId(), - nextRequest->size(), - prePrepareMsg.remainingSizeForRequests())); - return nullptr; // To break the outside loop that + "Request was dropped because it exceeds maximum allowed size" << KVLOG( + prePrepareMsg.seqNumber(), nextRequest->senderId(), nextRequest->size(), maxStorageForRequests)); + } else { + LOG_WARN(GL, + "Request was dropped because it exceeds the prePrepare remaining size" + << KVLOG(prePrepareMsg.seqNumber(), nextRequest->senderId(), nextRequest->size(), remaining_size)); + return nullptr; } primaryCombinedReqSize -= nextRequest->size(); requestsQueueOfPrimary.pop();