Skip to content

Commit

Permalink
Merge #35314
Browse files Browse the repository at this point in the history
35314: distsqlrun: assert there's at least a proc in a flow r=andreimatei a=andreimatei

The code was trying to protect against a flow with nothing in
flow.processors, but I don't think that's thing.
Code becomes clearer if we assume at least one processor.

Release note: None

Co-authored-by: Andrei Matei <[email protected]>
  • Loading branch information
craig[bot] and andreimatei committed Mar 3, 2019
2 parents d3b59b1 + 95a1737 commit de17935
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/sql/distsqlrun/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/rpc/nodedialer"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/sql/distsqlpb"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/sql/sessiondata"
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
Expand Down Expand Up @@ -605,10 +606,11 @@ func (f *Flow) Run(ctx context.Context, doneFn func()) error {

// We'll take care of the last processor in particular.
var headProc Processor
if len(f.processors) > 0 {
headProc = f.processors[len(f.processors)-1]
f.processors = f.processors[:len(f.processors)-1]
if len(f.processors) == 0 {
return pgerror.NewAssertionErrorf("no processors in flow")
}
headProc = f.processors[len(f.processors)-1]
f.processors = f.processors[:len(f.processors)-1]

if err := f.startInternal(ctx, doneFn); err != nil {
// For sync flows, the error goes to the consumer.
Expand All @@ -619,9 +621,7 @@ func (f *Flow) Run(ctx context.Context, doneFn func()) error {
}
return err
}
if headProc != nil {
headProc.Run(ctx)
}
headProc.Run(ctx)
return nil
}

Expand Down

0 comments on commit de17935

Please sign in to comment.