Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix visibility processor panic on add after stop #3830

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ func (p *processorImpl) hashFn(key interface{}) uint32 {

// Add request to the bulk and return a future object which will receive ack signal when request is processed.
func (p *processorImpl) Add(request *client.BulkableRequest, visibilityTaskKey string) *future.FutureImpl[bool] {
if p.mapToAckFuture == nil { // mapToAckFuture will be nil iff processor has been shut down
p.logger.Warn("Skipping ES request for visibility task key because processor has been shut down.", tag.Key(visibilityTaskKey), tag.ESDocID(request.ID), tag.Value(request.Doc))
return nil
}

newFuture := newAckFuture()
_, isDup, _ := p.mapToAckFuture.PutOrDo(visibilityTaskKey, newFuture, func(key interface{}, value interface{}) error {
existingFuture, ok := value.(*ackFuture)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ func (s *processorSuite) TestNewESProcessorAndStartStop() {
p.Stop()
s.Nil(p.mapToAckFuture)
s.Nil(p.bulkProcessor)

// Confirm processor does not panic on new requests after stopping
request := &client.BulkableRequest{}
visibilityTaskKey := "test-key"
future1 := p.Add(request, visibilityTaskKey)
s.Nil(future1)
}

func (s *processorSuite) TestAdd() {
Expand Down