damondouglas commented on code in PR #31028:
URL: https://github.com/apache/beam/pull/31028#discussion_r1572992754


##########
sdks/go/pkg/beam/runners/prism/internal/jobservices/management.go:
##########
@@ -243,21 +243,21 @@ func (s *Server) Run(ctx context.Context, req 
*jobpb.RunJobRequest) (*jobpb.RunJ
 // Otherwise, returns nil if Job does not exist or the Job's existing state as 
part of the CancelJobResponse.
 func (s *Server) Cancel(_ context.Context, req *jobpb.CancelJobRequest) 
(*jobpb.CancelJobResponse, error) {
        s.mu.Lock()
+       defer s.mu.Unlock()
        job, ok := s.jobs[req.GetJobId()]
-       s.mu.Unlock()
        if !ok {
                return nil, nil
        }
        state := job.state.Load().(jobpb.JobState_Enum)
        switch state {
-       case jobpb.JobState_CANCELLED, jobpb.JobState_DONE, 
jobpb.JobState_DRAINED, jobpb.JobState_UPDATED, jobpb.JobState_FAILED:
+       case jobpb.JobState_CANCELLED, jobpb.JobState_DONE, 
jobpb.JobState_DRAINED, jobpb.JobState_UPDATED, jobpb.JobState_FAILED, 
jobpb.JobState_STOPPED:
                // Already at terminal state.
                return &jobpb.CancelJobResponse{
                        State: state,
                }, nil
        }
        job.SendMsg("canceling " + job.String())
-       job.Canceling()
+       job.Canceled()

Review Comment:
   The underlying cause of me doing this was poorly written tests from 
misunderstanding the various lifecycles and when they should occur.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to