Skip to content

Commit

Permalink
fix(clustermgr): fix pendingkey memory release when add disk to dropp…
Browse files Browse the repository at this point in the history
…ed node

with #22402652

Signed-off-by: tangdeyi <[email protected]>
  • Loading branch information
tangdeyi authored and sejust committed Jul 29, 2024
1 parent 9622635 commit 9d392be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions blobstore/clustermgr/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (s *Service) DiskAdd(c *rpc.Context) {
}
err = s.DiskMgr.AddDisk(ctx, args)
if err != nil {
c.RespondError(err)
return
}
}
Expand Down
11 changes: 8 additions & 3 deletions blobstore/clustermgr/diskmgr/diskmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,16 @@ func (d *DiskMgr) AddDisk(ctx context.Context, args *blobnode.DiskInfo) error {
span.Errorf("json marshal failed, disk info: %v, error: %v", args, err)
return errors.Info(apierrors.ErrUnexpected).Detail(err)
}
pendingKey := fmtApplyContextKey("disk-add", args.DiskID.ToString())
d.pendingEntries.Store(pendingKey, nil)
defer d.pendingEntries.Delete(pendingKey)
proposeInfo := base.EncodeProposeInfo(d.GetModuleName(), OperTypeAddDisk, data, base.ProposeContext{ReqID: span.TraceID()})
err = d.raftServer.Propose(ctx, proposeInfo)
if err != nil {
span.Error(err)
return apierrors.ErrRaftPropose
}
if v, ok := d.pendingEntries.Load(fmtApplyContextKey("disk-add", args.DiskID.ToString())); ok {
d.pendingEntries.Delete(args.DiskID)
if v, _ := d.pendingEntries.Load(pendingKey); v != nil {
return v.(error)
}
return nil
Expand All @@ -849,7 +851,10 @@ func (d *DiskMgr) addDisk(ctx context.Context, info *blobnode.DiskInfo) error {
if node, ok := d.allNodes[info.NodeID]; ok {
if node.info.Status == proto.NodeStatusDropped {
span.Warnf("node is dropped, disk info: %v", info)
d.pendingEntries.Store(fmtApplyContextKey("disk-add", info.DiskID.ToString()), apierrors.ErrCMNodeNotFound)
pendingKey := fmtApplyContextKey("disk-add", info.DiskID.ToString())
if _, ok := d.pendingEntries.Load(pendingKey); ok {
d.pendingEntries.Store(pendingKey, apierrors.ErrCMNodeNotFound)
}
return nil
}
info.DiskSetID = d.topoMgrs[node.info.Role].AllocDiskSetID(ctx, info, node.info, d.CopySetConfigs[node.info.Role][node.info.DiskType])
Expand Down

0 comments on commit 9d392be

Please sign in to comment.