Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-22.2: sql: let extendedEvalContext.QueueJob() use txn from planner #91402

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 10 additions & 16 deletions pkg/jobs/jobs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2348,14 +2348,11 @@ func TestJobInTxn(t *testing.T) {
}
fn := func(ctx context.Context, _ []sql.PlanNode, _ chan<- tree.Datums) error {
var err error
job, err = execCtx.ExtendedEvalContext().QueueJob(
ctx,
jobs.Record{
Description: st.String(),
Details: jobspb.BackupDetails{},
Progress: jobspb.BackupProgress{},
},
)
job, err = execCtx.ExtendedEvalContext().QueueJob(ctx, execCtx.Txn(), jobs.Record{
Description: st.String(),
Details: jobspb.BackupDetails{},
Progress: jobspb.BackupProgress{},
})
return err
}
return fn, nil, nil, false, nil
Expand Down Expand Up @@ -2390,14 +2387,11 @@ func TestJobInTxn(t *testing.T) {
}
fn := func(ctx context.Context, _ []sql.PlanNode, _ chan<- tree.Datums) error {
var err error
job, err = execCtx.ExtendedEvalContext().QueueJob(
ctx,
jobs.Record{
Description: "RESTORE",
Details: jobspb.RestoreDetails{},
Progress: jobspb.RestoreProgress{},
},
)
job, err = execCtx.ExtendedEvalContext().QueueJob(ctx, execCtx.Txn(), jobs.Record{
Description: "RESTORE",
Details: jobspb.RestoreDetails{},
Progress: jobspb.RestoreProgress{},
})
return err
}
return fn, nil, nil, false, nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/drop_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func (p *planner) createDropSchemaJob(
typeIDs = append(typeIDs, t.ID)
}

_, err := p.extendedEvalCtx.QueueJob(p.EvalContext().Ctx(), jobs.Record{
_, err := p.extendedEvalCtx.QueueJob(p.EvalContext().Ctx(), p.Txn(), jobs.Record{
Description: jobDesc,
Username: p.User(),
DescriptorIDs: schemas,
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,14 @@ func (evalCtx *extendedEvalContext) copy() *extendedEvalContext {
// QueueJob creates a new job from record and queues it for execution after
// the transaction commits.
func (evalCtx *extendedEvalContext) QueueJob(
ctx context.Context, record jobs.Record,
ctx context.Context, txn *kv.Txn, record jobs.Record,
) (*jobs.Job, error) {
jobID := evalCtx.ExecCfg.JobRegistry.MakeJobID()
job, err := evalCtx.ExecCfg.JobRegistry.CreateJobWithTxn(
ctx,
record,
jobID,
evalCtx.Txn,
txn,
)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (p *planner) createDropDatabaseJob(
Progress: jobspb.SchemaChangeProgress{},
NonCancelable: true,
}
newJob, err := p.extendedEvalCtx.QueueJob(ctx, jobRecord)
newJob, err := p.extendedEvalCtx.QueueJob(ctx, p.Txn(), jobRecord)
if err != nil {
return err
}
Expand All @@ -92,7 +92,7 @@ func (p *planner) createNonDropDatabaseChangeJob(
Progress: jobspb.SchemaChangeProgress{},
NonCancelable: true,
}
newJob, err := p.extendedEvalCtx.QueueJob(ctx, jobRecord)
newJob, err := p.extendedEvalCtx.QueueJob(ctx, p.Txn(), jobRecord)
if err != nil {
return err
}
Expand Down