Skip to content

Commit

Permalink
Merge pull request cubefs#937 from yinlei-jinan/master
Browse files Browse the repository at this point in the history
fix: remove failed dp when create extent and fix RemoveDP bug for Def…
  • Loading branch information
awzhgw authored Sep 22, 2020
2 parents 6afb4f1 + cdfd90c commit 5bb1c9f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
11 changes: 3 additions & 8 deletions sdk/data/stream/extent_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package stream
import (
"fmt"
"net"
"strings"
"sync/atomic"
"time"

Expand Down Expand Up @@ -498,13 +497,9 @@ func (eh *ExtentHandler) allocateExtent() (err error) {
extID, err = eh.createExtent(dp)
}
if err != nil {
if strings.Contains(err.Error(), "DiskNoSpaceErr") {
log.LogWarnf("allocateExtent: delete dp[%v] caused by create extent failed, eh(%v) err(%v) exclude(%v)",
dp, eh, err, exclude)
eh.stream.client.dataWrapper.RemoveDataPartitionForWrite(dp.PartitionID)
continue
}
log.LogWarnf("allocateExtent: failed to create extent, eh(%v) err(%v) exclude(%v)", eh, err, exclude)
log.LogWarnf("allocateExtent: delete dp[%v] caused by create extent failed, eh(%v) err(%v) exclude(%v)",
dp, eh, err, exclude)
eh.stream.client.dataWrapper.RemoveDataPartitionForWrite(dp.PartitionID)
dp.CheckAllHostsIsAvail(exclude)
continue
}
Expand Down
7 changes: 6 additions & 1 deletion sdk/data/wrapper/default_random_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ func (s *DefaultRandomSelector) RemoveDP(partitionID uint64) {
newRwPartition = append(newRwPartition, rwPartitionGroups[:i]...)
newRwPartition = append(newRwPartition, rwPartitionGroups[i+1:]...)

defer func() {
s.Lock()
s.partitions = newRwPartition
s.Unlock()
}()

for i = 0; i < len(localLeaderPartitions); i++ {
if localLeaderPartitions[i].PartitionID == partitionID {
break
Expand All @@ -118,7 +124,6 @@ func (s *DefaultRandomSelector) RemoveDP(partitionID uint64) {

s.Lock()
defer s.Unlock()
s.partitions = newRwPartition
s.localLeaderPartitions = newLocalLeaderPartitions

return
Expand Down

0 comments on commit 5bb1c9f

Please sign in to comment.