Skip to content

Commit

Permalink
fix race condition with authctx
Browse files Browse the repository at this point in the history
  • Loading branch information
lyondhill committed Mar 27, 2019
1 parent 9ac885e commit c19d393
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion task/backend/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,11 @@ func (r *runner) executeAndWait(ctx context.Context, qr QueuedRun, runLogger *za

b, err := json.Marshal(stats)
if err == nil {
r.taskControlService.AddRunLog(r.ts.authCtx, r.task.ID, qr.RunID, time.Now(), string(b))
// authctx can be updated mid process
r.ts.nextDueMu.RLock()
authCtx := r.ts.authCtx
r.ts.nextDueMu.RUnlock()
r.taskControlService.AddRunLog(authCtx, r.task.ID, qr.RunID, time.Now(), string(b))
}
r.updateRunState(qr, RunSuccess, runLogger)
runLogger.Info("Execution succeeded")
Expand Down

0 comments on commit c19d393

Please sign in to comment.