Skip to content

Commit

Permalink
fix: partition is nil when apply remove raft node
Browse files Browse the repository at this point in the history
Signed-off-by: Tianpeng Li <[email protected]>
skypigltp authored and awzhgw committed Jun 11, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 369e157 commit e0d1ede
Showing 2 changed files with 6 additions and 12 deletions.
10 changes: 3 additions & 7 deletions datanode/partition_raft.go
Original file line number Diff line number Diff line change
@@ -257,10 +257,6 @@ func (dp *DataPartition) addRaftNode(req *proto.DataPartitionDecommissionRequest

// Delete a raft node.
func (dp *DataPartition) removeRaftNode(req *proto.DataPartitionDecommissionRequest, index uint64) (isUpdated bool, err error) {
if dp.raftPartition == nil {
err = fmt.Errorf("%s partitionID=%v applyid=%v", RaftNotStarted, dp.partitionID, index)
return
}
peerIndex := -1
for i, peer := range dp.config.Peers {
if peer.ID == req.RemovePeer.ID {
@@ -276,10 +272,10 @@ func (dp *DataPartition) removeRaftNode(req *proto.DataPartitionDecommissionRequ
go func(index uint64) {
for {
time.Sleep(time.Millisecond)
if dp.raftPartition.AppliedIndex() < index {
continue
}
if dp.raftPartition != nil {
if dp.raftPartition.AppliedIndex() < index {
continue
}
dp.raftPartition.Delete()
}
dp.Disk().space.DeletePartition(dp.partitionID)
8 changes: 3 additions & 5 deletions metanode/partition_fsmop.go
Original file line number Diff line number Diff line change
@@ -130,15 +130,13 @@ func (mp *metaPartition) confRemoveNode(req *proto.MetaPartitionDecommissionRequ
go func(index uint64) {
for {
time.Sleep(time.Millisecond)
if mp.raftPartition.AppliedIndex() < index {
continue
}
if mp.raftPartition != nil {
// TODO Unhandled errors
if mp.raftPartition.AppliedIndex() < index {
continue
}
mp.raftPartition.Delete()
}
mp.Stop()
// TODO Unhandled errors
os.RemoveAll(mp.config.RootDir)
log.LogDebugf("[confRemoveNode]: remove self end.")
return

0 comments on commit e0d1ede

Please sign in to comment.