Skip to content
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

[FLASH-222] Raft Cmd ChangePeer Should Update Conf Version #43

Merged
merged 2 commits into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 2 additions & 17 deletions dbms/src/Storages/Transaction/RegionMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,6 @@ void RegionMeta::reset(RegionMeta && rhs)
pending_remove = rhs.pending_remove;
}

void RegionMeta::doRemovePeer(UInt64 store_id)
{
auto mutable_peers = region.mutable_peers();

for (auto it = mutable_peers->begin(); it != mutable_peers->end(); ++it)
{
if (it->store_id() == store_id)
{
mutable_peers->erase(it);
return;
}
}
throw Exception("peer with store_id " + DB::toString(store_id) + " not found", ErrorCodes::LOGICAL_ERROR);
}

void RegionMeta::execChangePeer(
const raft_cmdpb::AdminRequest & request, const raft_cmdpb::AdminResponse & response, UInt64 index, UInt64 term)
{
Expand All @@ -243,14 +228,14 @@ void RegionMeta::execChangePeer(
case eraftpb::ConfChangeType::RemoveNode:
{
const auto & peer = change_peer_request.peer();
auto store_id = peer.store_id();

std::lock_guard<std::mutex> lock(mutex);

doRemovePeer(store_id);
doSetRegion(new_region);

if (this->peer.id() == peer.id())
doSetPendingRemove();

doSetApplied(index, term);
return;
}
Expand Down
2 changes: 0 additions & 2 deletions dbms/src/Storages/Transaction/RegionMeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ class RegionMeta
void execChangePeer(const raft_cmdpb::AdminRequest & request, const raft_cmdpb::AdminResponse & response, UInt64 index, UInt64 term);

private:
void doRemovePeer(UInt64 store_id);

void doSetPendingRemove();

void doSetRegion(const metapb::Region & region);
Expand Down