Skip to content

Commit

Permalink
fix(api): run multiple join in parallel (#3613)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux committed Nov 20, 2018
1 parent e86c5f4 commit e002fb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion engine/api/workflow/process_data.go
Expand Up @@ -84,7 +84,7 @@ func processWorkflowDataRun(ctx context.Context, db gorp.SqlExecutor, store cach
}
report, _ = report.Merge(r1, nil)

r2, errJ := processAllJoins(ctx, db, store, proj, wr, mapNodes, maxsn)
r2, errJ := processAllJoins(ctx, db, store, proj, wr, mapNodes)
if errJ != nil {
return nil, false, errJ
}
Expand Down
8 changes: 5 additions & 3 deletions engine/api/workflow/process_start.go
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/go-gorp/gorp"

"github.com/ovh/cds/engine/api/cache"
"github.com/ovh/cds/sdk"
"github.com/ovh/cds/sdk/log"
Expand Down Expand Up @@ -85,7 +86,7 @@ func processAllNodesTriggers(ctx context.Context, db gorp.SqlExecutor, store cac
return report, nil
}

func processAllJoins(ctx context.Context, db gorp.SqlExecutor, store cache.Store, proj *sdk.Project, wr *sdk.WorkflowRun, mapNodes map[int64]*sdk.Node, maxsn int64) (*ProcessorReport, error) {
func processAllJoins(ctx context.Context, db gorp.SqlExecutor, store cache.Store, proj *sdk.Project, wr *sdk.WorkflowRun, mapNodes map[int64]*sdk.Node) (*ProcessorReport, error) {
report := new(ProcessorReport)
//Checks the joins
for i := range wr.Workflow.WorkflowData.Joins {
Expand Down Expand Up @@ -118,7 +119,7 @@ func processAllJoins(ctx context.Context, db gorp.SqlExecutor, store cache.Store
break
}

if !sdk.StatusIsTerminated(nodeRun.Status) || nodeRun.Status == sdk.StatusNeverBuilt.String() || nodeRun.Status == sdk.StatusStopped.String() || nodeRun.SubNumber < maxsn {
if !sdk.StatusIsTerminated(nodeRun.Status) || nodeRun.Status == sdk.StatusNeverBuilt.String() || nodeRun.Status == sdk.StatusStopped.String() || nodeRun.SubNumber < wr.LastSubNumber {
//One of the sources have not been completed
ok = false
break
Expand All @@ -136,9 +137,10 @@ func processAllJoins(ctx context.Context, db gorp.SqlExecutor, store cache.Store
if len(sources) != len(j.JoinContext) {
ok = false
}

//All the sources are completed
if ok {
r1, _, err := processNode(ctx, db, store, proj, wr, mapNodes, j, int(wr.LastSubNumber), sources, nil, nil)
r1, _, err := processNodeRun(ctx, db, store, proj, wr, mapNodes, j, int(wr.LastSubNumber), sources, nil, nil)
if err != nil {
return report, sdk.WrapError(err, "processAllJoins> Unable to process join node")
}
Expand Down

0 comments on commit e002fb4

Please sign in to comment.