Commit b1d7bc2d authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

Slightly simplify buildPayload method in RaftReplicator

parent 4020e0ff
Pipeline #1481388 passed with stages
in 142 minutes and 30 seconds
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
## Unreleased ## Unreleased
### Bug fixes ### Bug fixes
- Under complicated conditions, replication towards a particular follower could become stuck. - Under complicated conditions (follower is very far behind leader + network instabilities),
(to workaround, restart leader node) replication towards a particular follower could become stuck. (to workaround, restart leader node)
- Running ``DEL`` on a lease key would cause all nodes in a cluster to crash - Running ``DEL`` on a lease key would cause all nodes in a cluster to crash
with an assertion. ``DEL`` will now simply release the given lease, as if with an assertion. ``DEL`` will now simply release the given lease, as if
``lease-release`` had been called. ``lease-release`` had been called.
...@@ -21,8 +21,9 @@ checkpoint for long-term storage. ...@@ -21,8 +21,9 @@ checkpoint for long-term storage.
- Attempt to detect potential ``MANIFEST`` corruption early by measuring mtime lag - Attempt to detect potential ``MANIFEST`` corruption early by measuring mtime lag
compared to newest SST file. compared to newest SST file.
Many thanks to Pete Eby (ORNL) for finding and reporting the bug causing replication Many thanks to Crystal Chua (AARNet) for the bug report and all support offered
to become stuck. related to RocksDB's ``MANIFEST`` corruption issue, as well as to Pete Eby (ORNL)
for finding and reporting the bug causing replication to become stuck.
## 0.4.1 (2020-01-17) ## 0.4.1 (2020-01-17)
......
...@@ -91,9 +91,9 @@ RaftReplicaTracker::~RaftReplicaTracker() { ...@@ -91,9 +91,9 @@ RaftReplicaTracker::~RaftReplicaTracker() {
} }
bool RaftReplicaTracker::buildPayload(LogIndex nextIndex, int64_t payloadLimit, bool RaftReplicaTracker::buildPayload(LogIndex nextIndex, int64_t payloadLimit,
std::vector<std::string> &entries, int64_t &payloadSize, RaftTerm &lastEntryTerm) { std::vector<std::string> &entries, RaftTerm &lastEntryTerm) {
payloadSize = std::min(payloadLimit, journal.getLogSize() - nextIndex); int64_t payloadSize = std::min(payloadLimit, journal.getLogSize() - nextIndex);
entries.resize(payloadSize); entries.resize(payloadSize);
RaftJournal::Iterator iterator = journal.getIterator(nextIndex, true); RaftJournal::Iterator iterator = journal.getIterator(nextIndex, true);
...@@ -322,11 +322,13 @@ bool RaftReplicaTracker::sendPayload(RaftTalker &talker, LogIndex nextIndex, int ...@@ -322,11 +322,13 @@ bool RaftReplicaTracker::sendPayload(RaftTalker &talker, LogIndex nextIndex, int
LogIndex commitIndexForTarget = journal.getCommitIndex(); LogIndex commitIndexForTarget = journal.getCommitIndex();
std::vector<RaftSerializedEntry> entries; std::vector<RaftSerializedEntry> entries;
if(!buildPayload(nextIndex, payloadLimit, entries, payloadSize, lastEntryTerm)) { if(!buildPayload(nextIndex, payloadLimit, entries, lastEntryTerm)) {
state.observed(snapshot->term+1, {}); state.observed(snapshot->term+1, {});
return false; return false;
} }
payloadSize = entries.size();
contact = std::chrono::steady_clock::now(); contact = std::chrono::steady_clock::now();
reply = talker.appendEntries( reply = talker.appendEntries(
snapshot->term, snapshot->term,
......
...@@ -82,7 +82,7 @@ private: ...@@ -82,7 +82,7 @@ private:
void triggerResilvering(); void triggerResilvering();
bool buildPayload(LogIndex nextIndex, int64_t payloadLimit, std::vector<RaftSerializedEntry> &entries, bool buildPayload(LogIndex nextIndex, int64_t payloadLimit, std::vector<RaftSerializedEntry> &entries,
int64_t &payloadSize, RaftTerm &lastEntryTerm); RaftTerm &lastEntryTerm);
bool sendPayload(RaftTalker &talker, LogIndex nextIndex, int64_t payloadLimit, bool sendPayload(RaftTalker &talker, LogIndex nextIndex, int64_t payloadLimit,
std::future<redisReplyPtr> &reply, std::chrono::steady_clock::time_point &contact, int64_t &payloadSize, std::future<redisReplyPtr> &reply, std::chrono::steady_clock::time_point &contact, int64_t &payloadSize,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment