Skip to content

Commit

Permalink
Avoid panics on not owner errors because they should go away (#169)
Browse files Browse the repository at this point in the history
* Avoid panics on not owner errors because they should go away

* Apply suggestions from code review

Co-authored-by: Eric Sniff <[email protected]>

Co-authored-by: Eric Sniff <[email protected]>
  • Loading branch information
ajroetker and epsniff committed Jun 29, 2021
1 parent a9b90db commit c343163
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mailbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"
"time"

"github.com/lytics/grid/v3/registry"
"github.com/lytics/retry"
)

Expand Down Expand Up @@ -164,7 +165,10 @@ func newMailbox(s *Server, name, nsName string, size int) (*Mailbox, error) {
cancel()
return err != nil
})
if err != nil {
// Ingnore ErrNotOwner because most likely the previous owner panic'ed or exited badly.
// So we'll ignore the error and let the mailbox creator retry later. We don't want to panic
// in that case because it will take down more mailboxes and make it worse.
if err != nil && err != registry.ErrNotOwner {
panic(fmt.Errorf("%w: unable to deregister mailbox: %v, error: %v", errDeregisteredFailed, nsName, err))
}
}
Expand Down
5 changes: 4 additions & 1 deletion server.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ func (s *Server) deregisterActor(nsName string) {
cancel()
return err != nil
})
if err != nil {
// Ingnore ErrNotOwner because most likely the previous owner panic'ed or exited badly.
// So we'll ignore the error and let the mailbox creator retry later. We don't want to panic
// in that case because it will take down more mailboxes and make it worse.
if err != nil && err != registry.ErrNotOwner {
panic(fmt.Sprintf("unable to deregister actor: %v, error: %v", nsName, err))
}
}
Expand Down

0 comments on commit c343163

Please sign in to comment.