Skip to content

Commit

Permalink
Merge pull request #108927 from msbutler/butler-patch-job-txn
Browse files Browse the repository at this point in the history
release-22.2: jobs: pass explicit transaction to lookup-num-running query
  • Loading branch information
msbutler authored Aug 17, 2023
2 parents 211ac9d + d76c407 commit e5ff2bd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/jobs/job_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@ func lookupNumRunningJobs(
scheduleID int64,
env scheduledjobs.JobSchedulerEnv,
ie sqlutil.InternalExecutor,
txn *kv.Txn,
) (int64, error) {
lookupStmt := fmt.Sprintf(
"SELECT count(*) FROM %s WHERE created_by_type = '%s' AND created_by_id = %d AND status IN %s",
env.SystemJobsTableName(), CreatedByScheduledJobs, scheduleID, NonTerminalStatusTupleString)
row, err := ie.QueryRowEx(
ctx, "lookup-num-running",
/*txn=*/ nil,
txn,
sessiondata.InternalExecutorOverride{User: username.RootUserName()},
lookupStmt)
if err != nil {
Expand Down Expand Up @@ -254,7 +255,7 @@ func (s *jobScheduler) executeCandidateSchedule(
return nil
}

numRunning, err := lookupNumRunningJobs(ctx, schedule.ScheduleID(), s.env, s.InternalExecutor)
numRunning, err := lookupNumRunningJobs(ctx, schedule.ScheduleID(), s.env, s.InternalExecutor, txn)
if err != nil {
return err
}
Expand Down

0 comments on commit e5ff2bd

Please sign in to comment.