Skip to content

Commit

Permalink
Fix errcheck in service/matching (#3756)
Browse files Browse the repository at this point in the history
Add some more error-handling to service/matching
  • Loading branch information
MichaelSnowden authored Dec 23, 2022
1 parent ba2d711 commit 825d39c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions service/matching/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ func (t *MatcherTestSuite) TestQueryRemoteSyncMatch() {
task.forwardedFrom = req.GetForwardedSource()
close(pollSigC)
time.Sleep(10 * time.Millisecond)
t.rootMatcher.OfferQuery(ctx, task)
_, err := t.rootMatcher.OfferQuery(ctx, task)
t.Assert().NoError(err)
},
).Return(&matchingservice.QueryWorkflowResponse{QueryResult: payloads.EncodeString("answer")}, nil)

Expand Down Expand Up @@ -386,7 +387,8 @@ func (t *MatcherTestSuite) TestMustOfferRemoteMatch() {

go func() {
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Second)
t.matcher.Poll(ctx)
_, err := t.matcher.Poll(ctx)
t.Assert().NoError(err)
cancel()
}()

Expand Down
4 changes: 3 additions & 1 deletion service/matching/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func (s *Service) Stop() {

// remove self from membership ring and wait for traffic to drain
s.logger.Info("ShutdownHandler: Evicting self from membership ring")
s.membershipMonitor.EvictSelf()
if err := s.membershipMonitor.EvictSelf(); err != nil {
s.logger.Error("ShutdownHandler: Failed to evict self from membership ring", tag.Error(err))
}
s.healthServer.SetServingStatus(serviceName, healthpb.HealthCheckResponse_NOT_SERVING)
s.logger.Info("ShutdownHandler: Waiting for others to discover I am unhealthy")
time.Sleep(s.config.ShutdownDrainDuration())
Expand Down
4 changes: 3 additions & 1 deletion service/matching/taskQueueManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ func (c *taskQueueManagerImpl) Stop() {
ctx, cancel := c.newIOContext()
defer cancel()

c.db.UpdateState(ctx, ackLevel)
if err := c.db.UpdateState(ctx, ackLevel); err != nil {
c.logger.Error("Failed to update task queue state", tag.Error(err))
}
c.taskGC.RunNow(ctx, ackLevel)
}
c.metadataPoller.Stop()
Expand Down
2 changes: 1 addition & 1 deletion service/matching/taskReader.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Loop:

// only error here is due to context cancelation which we also
// handle above
tr.addTasksToBuffer(ctx, tasks)
_ = tr.addTasksToBuffer(ctx, tasks)
// There maybe more tasks. We yield now, but signal pump to check again later.
tr.Signal()

Expand Down

0 comments on commit 825d39c

Please sign in to comment.