-
Notifications
You must be signed in to change notification settings - Fork 857
Bug fix/agency restart after compaction and holes in log #3413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
57a8d38
e251d66
4d43a87
a45f7b1
449d115
0d70579
317f83c
52d990b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -865,6 +865,7 @@ bool State::loadRemaining() { | |
|
||
TRI_ASSERT(_log.empty()); // was cleared in loadCompacted | ||
std::string clientId; | ||
index_t lastIndex = 0; | ||
for (auto const& i : VPackArrayIterator(result)) { | ||
|
||
buffer_t tmp = std::make_shared<arangodb::velocypack::Buffer<uint8_t>>(); | ||
|
@@ -876,6 +877,21 @@ bool State::loadRemaining() { | |
clientId = req.hasKey("clientId") ? | ||
req.get("clientId").copyString() : std::string(); | ||
|
||
// Dummy fill missing entries (Not good at all.) | ||
index_t index(basics::StringUtils::uint64( | ||
ii.get(StaticStrings::KeyString).copyString())); | ||
term_t term(ii.get("term").getNumber<uint64_t>()); | ||
if (lastIndex > 0 && index-lastIndex > 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not very robust. Why lastIndex > 0? How do we know that index >= lastIndex and there is no overflow? If index < lastIndex, we must not append at all. If index == lastIndex, we must append if and only if _log is still empty. If index == lastIndex+1 we must append normally and move lastIndex one up. If index > lastindex+1, then we must insert empty entries until index == lastIndex+1. |
||
std::shared_ptr<Buffer<uint8_t>> buf = | ||
std::make_shared<Buffer<uint8_t>>(); | ||
VPackSlice value = arangodb::basics::VelocyPackHelper::EmptyObjectValue(); | ||
buf->append(value.startAs<char const>(), value.byteSize()); | ||
for (index_t i = lastIndex+1; i < index; ++i) { | ||
LOG_TOPIC(WARN, Logger::AGENCY) << "Missing index " << i << " in RAFT log."; | ||
_log.push_back(log_t(i, term, buf, std::string())); | ||
} | ||
} | ||
|
||
try { | ||
_log.push_back( | ||
log_t( | ||
|
@@ -889,6 +905,9 @@ bool State::loadRemaining() { | |
" to integer." | ||
<< e.what(); | ||
} | ||
|
||
lastIndex = index; | ||
|
||
} | ||
} | ||
if (_log.empty()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lastIndex should probably be initialized with _cur, which has been set to the index of the latest snapshot in
loadCompacted
just beforeloadRemaining
was called. I think 0 is wrong if there is a persisted snapshot.