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


##########
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:

Review Comment:
   I previously misunderstood the order and reason of the Prepare, Run 
lifecycle and their relationship with Job state. Consequently, I misunderstood 
the purposes of the noJobsCheck, postPrepCheck, and postRunCheck. Now that I 
do, I refactored the tests and got expected results as well as uncover errors 
in Cancel with respect to these lifecycles.



-- 
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