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

bulkio: use correct context in processor initialization #60958

Merged
merged 2 commits into from
Feb 23, 2021
Merged
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
8 changes: 1 addition & 7 deletions pkg/ccl/backupccl/backup_processor.go
Original file line number Diff line number Diff line change
@@ -109,17 +109,11 @@ func newBackupDataProcessor(

// Start is part of the RowSource interface.
func (bp *backupDataProcessor) Start(ctx context.Context) {
ctx = bp.StartInternal(ctx, backupProcessorName)
go func() {
defer close(bp.progCh)
bp.backupErr = runBackupProcessor(ctx, bp.flowCtx, &bp.spec, bp.progCh)
}()
ctx = bp.StartInternal(ctx, backupProcessorName)
// Go around "this value of ctx is never used" linter error. We do it this
// way instead of omitting the assignment to ctx above so that if in the
// future other initialization is added, the correct ctx is used.
// TODO(bulkio): check whether this context should be used in the closure
// above.
_ = ctx
}

// Next is part of the RowSource interface.
8 changes: 1 addition & 7 deletions pkg/ccl/backupccl/split_and_scatter_processor.go
Original file line number Diff line number Diff line change
@@ -203,6 +203,7 @@ func newSplitAndScatterProcessor(

// Start is part of the RowSource interface.
func (ssp *splitAndScatterProcessor) Start(ctx context.Context) {
ctx = ssp.StartInternal(ctx, splitAndScatterProcessorName)
go func() {
// Note that the loop over doneScatterCh in Next should prevent this
// goroutine from leaking when there are no errors. However, if that loop
@@ -213,13 +214,6 @@ func (ssp *splitAndScatterProcessor) Start(ctx context.Context) {
defer close(ssp.doneScatterCh)
ssp.scatterErr = ssp.runSplitAndScatter(scatterCtx, ssp.flowCtx, &ssp.spec, ssp.scatterer)
}()
ctx = ssp.StartInternal(ctx, splitAndScatterProcessorName)
// Go around "this value of ctx is never used" linter error. We do it this
// way instead of omitting the assignment to ctx above so that if in the
// future other initialization is added, the correct ctx is used.
// TODO(bulkio): check whether this context should be used in the closure
// above.
_ = ctx
}

type entryNode struct {
8 changes: 1 addition & 7 deletions pkg/ccl/importccl/import_processor.go
Original file line number Diff line number Diff line change
@@ -100,20 +100,14 @@ func newReadImportDataProcessor(

// Start is part of the RowSource interface.
func (idp *readImportDataProcessor) Start(ctx context.Context) {
ctx = idp.StartInternal(ctx, readImportDataProcessorName)
// We don't have to worry about this go routine leaking because next we loop over progCh
// which is closed only after the go routine returns.
go func() {
defer close(idp.progCh)
idp.summary, idp.importErr = runImport(ctx, idp.flowCtx, &idp.spec, idp.progCh,
idp.seqChunkProvider)
}()
ctx = idp.StartInternal(ctx, readImportDataProcessorName)
// Go around "this value of ctx is never used" linter error. We do it this
// way instead of omitting the assignment to ctx above so that if in the
// future other initialization is added, the correct ctx is used.
// TODO(bulkio): check whether this context should be used in the closure
// above.
_ = ctx
}

// Next is part of the RowSource interface.
4 changes: 2 additions & 2 deletions pkg/ccl/logictestccl/testdata/logic_test/multi_region_backup
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# LogicTest: multiregion-9node-3region-3azs

skip flaky # see #60773

query TTTT
SHOW REGIONS
----
@@ -677,8 +679,6 @@ postgres
system
test

skip flaky # see #60773

statement ok
RESTORE DATABASE "mr-backup-1", "mr-backup-2" FROM 'nodelocal://1/mr-backup-combined/'

10 changes: 3 additions & 7 deletions pkg/ccl/streamingccl/streamingest/stream_ingestion_processor.go
Original file line number Diff line number Diff line change
@@ -157,15 +157,11 @@ func newStreamIngestionDataProcessor(
// Start is part of the RowSource interface.
func (sip *streamIngestionProcessor) Start(ctx context.Context) {
ctx = sip.StartInternal(ctx, streamIngestionProcessorName)
// Go around "this value of ctx is never used" linter error. We do it this
// way instead of omitting the assignment to ctx above so that if in the
// future other initialization is added, the correct ctx is used.
_ = ctx

evalCtx := sip.FlowCtx.EvalCtx
db := sip.FlowCtx.Cfg.DB
var err error
sip.batcher, err = bulk.MakeStreamSSTBatcher(sip.Ctx, db, evalCtx.Settings,
sip.batcher, err = bulk.MakeStreamSSTBatcher(ctx, db, evalCtx.Settings,
func() int64 { return storageccl.MaxImportBatchSize(evalCtx.Settings) })
if err != nil {
sip.MoveToDraining(errors.Wrap(err, "creating stream sst batcher"))
@@ -176,14 +172,14 @@ func (sip *streamIngestionProcessor) Start(ctx context.Context) {
startTime := timeutil.Unix(0 /* sec */, sip.spec.StartTime.WallTime)
eventChs := make(map[streamingccl.PartitionAddress]chan streamingccl.Event)
for _, partitionAddress := range sip.spec.PartitionAddresses {
eventCh, err := sip.client.ConsumePartition(sip.Ctx, partitionAddress, startTime)
eventCh, err := sip.client.ConsumePartition(ctx, partitionAddress, startTime)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yuzefovich Just wanted to check if there was a convention to use ctx here rather than sip.Ctx?

if err != nil {
sip.MoveToDraining(errors.Wrapf(err, "consuming partition %v", partitionAddress))
return
}
eventChs[partitionAddress] = eventCh
}
sip.eventCh = sip.merge(sip.Ctx, eventChs)
sip.eventCh = sip.merge(ctx, eventChs)
}

// Next is part of the RowSource interface.