Skip to content

Commit

Permalink
[IMPROVED] Revamped fallback cleanup of consumer raft directory. (#5028)
Browse files Browse the repository at this point in the history
We used to more broadly try to cleanup directories under a consumer.
This could cause issues with reports of missing "tav.idx" etc.

This only scopes to then the account has been removed from the server.

Signed-off-by: Derek Collison <derek@nats.io>
  • Loading branch information
derekcollison committed Feb 2, 2024
2 parents 97bd0e1 + 77721d0 commit 716e30c
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions server/jetstream_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -4392,7 +4392,6 @@ func (js *jetStream) processClusterDeleteConsumer(ca *consumerAssignment, isMemb
recovering := ca.recovering
js.mu.RUnlock()

stopped := false
var resp = JSApiConsumerDeleteResponse{ApiResponse: ApiResponse{Type: JSApiConsumerDeleteResponseType}}
var err error
var acc *Account
Expand All @@ -4402,25 +4401,20 @@ func (js *jetStream) processClusterDeleteConsumer(ca *consumerAssignment, isMemb
if mset, _ := acc.lookupStream(ca.Stream); mset != nil {
if o := mset.lookupConsumer(ca.Name); o != nil {
err = o.stopWithFlags(true, false, true, wasLeader)
stopped = true
}
}
} else if ca.Group != nil {
// We have a missing account, see if we can cleanup.
if sacc := s.SystemAccount(); sacc != nil {
os.RemoveAll(filepath.Join(js.config.StoreDir, sacc.GetName(), defaultStoreDirName, ca.Group.Name))
}
}

// Always delete the node if present.
if node != nil {
node.Delete()
}

// This is a stop gap cleanup in case
// 1) the account does not exist (and mset consumer couldn't be stopped) and/or
// 2) node was nil (and couldn't be deleted)
if !stopped || node == nil {
if sacc := s.SystemAccount(); sacc != nil {
os.RemoveAll(filepath.Join(js.config.StoreDir, sacc.GetName(), defaultStoreDirName, ca.Group.Name))
}
}

if !wasLeader || ca.Reply == _EMPTY_ {
if !(offline && isMetaLeader) {
return
Expand Down

0 comments on commit 716e30c

Please sign in to comment.