8000 [R2] Log Multiplexer by maierlars · Pull Request #14667 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

[R2] Log Multiplexer #14667

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Renamed commitIndex to currentCommitIndex in waitForResult.
  • Loading branch information
maierlars committed Sep 1, 2021
commit b7c6eaaf2f945325afbc7534829e4d95a2122690
6 changes: 3 additions & 3 deletions arangod/Replication2/ReplicatedLog/ILogParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ auto replicated_log::LogUnconfiguredParticipant::release(LogIndex doneWithIdx) -

replicated_log::WaitForResult::WaitForResult(LogIndex index,
std::shared_ptr<QuorumData const> quorum)
: commitIndex(index), quorum(std::move(quorum)) {}
: currentCommitIndex(index), quorum(std::move(quorum)) {}

void replicated_log::WaitForResult::toVelocyPack(velocypack::Builder& builder) const {
VPackObjectBuilder ob(&builder);
builder.add(StaticStrings::CommitIndex, VPackValue(commitIndex));
builder.add(StaticStrings::CommitIndex, VPackValue(currentCommitIndex));
builder.add(VPackValue("quorum"));
quorum->toVelocyPack(builder);
}

replicated_log::WaitForResult::WaitForResult(velocypack::Slice s) {
commitIndex = s.get(StaticStrings::CommitIndex).extract<LogIndex>();
currentCommitIndex = s.get(StaticStrings::CommitIndex).extract<LogIndex>();
quorum = std::make_shared<QuorumData>(s.get("quorum"));
}
2 changes: 1 addition & 1 deletion arangod/Replication2/ReplicatedLog/ILogParticipant.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct LogStatus;

struct WaitForResult {
/// @brief contains the _current_ commit index. (Not the index waited for)
LogIndex commitIndex;
LogIndex currentCommitIndex;
/// @brief Quorum information
std::shared_ptr<QuorumData const> quorum;

Expand Down
13 changes: 5 additions & 8 deletions arangod/Replication2/Streams/LogMultiplexer.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,8 @@ struct LogMultiplexerImplementationBase {
template <typename StreamDescriptor, typename T = stream_descriptor_type_t<StreamDescriptor>,
typename E = StreamEntryView<T>>
auto getIteratorInternal() -> std::unique_ptr<TypedLogRangeIterator<E>> {
using BlockType = StreamInformationBlock<StreamDescriptor>;

return _guardedData.template doUnderLock([](MultiplexerData<Spec>& self) {
auto& block = std::get<BlockType>(self._blocks);
auto& block = self.template getBlockForDescriptor<StreamDescriptor>();
return block.getIterator();
});
}
Expand Down Expand Up @@ -216,9 +214,8 @@ struct LogDemultiplexerImplementation
: LogDemultiplexer<Spec>, // implement the actual class
ProxyStreamDispatcher<LogDemultiplexerImplementation<Spec, Interface>, Spec, Stream>, // use a proxy stream dispatcher
LogMultiplexerImplementationBase<LogDemultiplexerImplementation<Spec, Interface>, Spec, Stream, Interface> {
using SelfClass = LogDemultiplexerImplementation<Spec, Interface>;
explicit LogDemultiplexerImplementation(std::shared_ptr<Interface> interface)
: LogMultiplexerImplementationBase<LogDemultiplexerImplementation<Spec, Interface>, Spec, Stream, Interface>(
: LogMultiplexerImplementationBase<LogDemultiplexerImplementation, Spec, Stream, Interface>(
std::move(interface)) {}

auto digestIterator(LogRangeIterator& iter) -> void override {
Expand All @@ -244,7 +241,7 @@ struct LogDemultiplexerImplementation
this->_interface->waitForIterator(waitForIndex)
.thenValue([weak = this->weak_from_this()](std::unique_ptr<LogRangeIterator>&& iter) {
if (auto locked = weak.lock(); locked) {
auto that = std::static_pointer_cast<SelfClass>(locked);
auto that = std::static_pointer_cast<LogDemultiplexerImplementation>(locked);
auto [nextIndex, promiseSets] = that->_guardedData.doUnderLock([&](auto& self) {
self._firstUncommittedIndex = iter->range().second;
self.digestIterator(*iter);
Expand Down Expand Up @@ -314,8 +311,8 @@ struct LogMultiplexerImplementation
self._pendingWaitFor = false;

// find out what the commit index is
self._firstUncommittedIndex = result.commitIndex + 1;
return std::make_pair(self.getWaitForResolveSetAll(result.commitIndex),
self._firstUncommittedIndex = result.currentCommitIndex + 1;
return std::make_pair(self.getWaitForResolveSetAll(result.currentCommitIndex),
self.checkWaitFor());
});

Expand Down
2 changes: 1 addition & 1 deletion tests/Replication2/ReplicatedLog/MultiTermTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ TEST_F(MultiTermTest, resign_leader_append_entries) {
ASSERT_TRUE(f2.isReady());
{
auto result = f2.get();
EXPECT_EQ(result.commitIndex, LogIndex{3});
EXPECT_EQ(result.currentCommitIndex, LogIndex{3});
EXPECT_EQ(result.quorum->index, LogIndex{3});
EXPECT_EQ(result.quorum->term, LogTerm{2});
EXPECT_EQ(result.quorum->quorum,
Expand Down
4 changes: 2 additions & 2 deletions tests/Replication2/ReplicatedLog/SimpleInsertTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ TEST_F(ReplicatedLogTest, write_single_entry_to_follower) {
// Expect the quorum to consist of the follower only
ASSERT_TRUE(f.isReady());
auto result = f.get();
EXPECT_EQ(result.commitIndex, LogIndex{2});
EXPECT_EQ(result.currentCommitIndex, LogIndex{2});
EXPECT_EQ(result.quorum->index, LogIndex{2});
EXPECT_EQ(result.quorum->term, LogTerm{1});
EXPECT_EQ(result.quorum->quorum, (std::vector<ParticipantId>{leaderId, followerId}));
Expand Down Expand Up @@ -382,7 +382,7 @@ TEST_F(ReplicatedLogTest, multiple_follower) {
{
ASSERT_TRUE(future.isReady());
auto result = future.get();
EXPECT_EQ(result.commitIndex, LogIndex{2});
EXPECT_EQ(result.currentCommitIndex, LogIndex{2});
EXPECT_EQ(result.quorum->term, LogTerm{1});
EXPECT_EQ(result.quorum->index, LogIndex{2});
EXPECT_EQ(result.quorum->quorum, (std::vector{leaderId, followerId_1, followerId_2}));
Expand Down
0