Skip to content

Commit

Permalink
fix(api): release mutex when stopping a node run (#5216)
Browse files Browse the repository at this point in the history
* fix(api): release mutex when stopping a node run
* test: check release mutex on older run first
* fix: add missing check has mutex
  • Loading branch information
richardlt committed May 28, 2020
1 parent 96a798c commit 36673fd
Show file tree
Hide file tree
Showing 4 changed files with 505 additions and 212 deletions.
23 changes: 12 additions & 11 deletions engine/api/workflow/dao_node_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,13 @@ func LoadNodeRunByID(db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*s
testsField = withLightNodeRunTestsField
}

query := fmt.Sprintf(`select %s %s
from workflow_node_run
where workflow_node_run.id = $1`, nodeRunFields, testsField)
query := fmt.Sprintf(`
SELECT %s %s
FROM workflow_node_run
WHERE workflow_node_run.id = $1
`, nodeRunFields, testsField)
if err := db.SelectOne(&rr, query, id); err != nil {
return nil, sdk.WrapError(err, "Unable to load workflow_node_run node=%d", id)
return nil, sdk.WrapError(err, "unable to load workflow_node_run with id %d", id)
}

r, err := fromDBNodeRun(rr, loadOpts)
Expand All @@ -207,23 +209,22 @@ func LoadNodeRunByID(db gorp.SqlExecutor, id int64, loadOpts LoadRunOptions) (*s
}

if loadOpts.WithArtifacts {
arts, errA := loadArtifactByNodeRunID(db, r.ID)
if errA != nil {
return nil, sdk.WrapError(errA, "LoadNodeRunByID>Error loading artifacts for run %d", r.ID)
arts, err := loadArtifactByNodeRunID(db, r.ID)
if err != nil {
return nil, sdk.WrapError(err, "cannot load artifacts for workflow node run %d", r.ID)
}
r.Artifacts = arts
}

if loadOpts.WithStaticFiles {
staticFiles, errS := loadStaticFilesByNodeRunID(db, r.ID)
if errS != nil {
return nil, sdk.WrapError(errS, "LoadNodeRunByID>Error loading static files for run %d", r.ID)
staticFiles, err := loadStaticFilesByNodeRunID(db, r.ID)
if err != nil {
return nil, sdk.WrapError(err, "cannot load static files for workflow node run %d", r.ID)
}
r.StaticFiles = staticFiles
}

return r, nil

}

//insertWorkflowNodeRun insert in table workflow_node_run
Expand Down

0 comments on commit 36673fd

Please sign in to comment.