This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch release-v0.14
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.14 by this push:
new 415c65ccc fix: maybe can fix dbt zombie processes (#4101)
415c65ccc is described below
commit 415c65ccc206fb458738d37b09d2320b1272094c
Author: abeizn <[email protected]>
AuthorDate: Wed Jan 4 18:26:43 2023 +0800
fix: maybe can fix dbt zombie processes (#4101)
* fix: maybe can fix dbt zombie processes
* fix: maybe can fix dbt zombie processes
---
plugins/dbt/tasks/convertor.go | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/plugins/dbt/tasks/convertor.go b/plugins/dbt/tasks/convertor.go
index cd6580256..7115e660f 100644
--- a/plugins/dbt/tasks/convertor.go
+++ b/plugins/dbt/tasks/convertor.go
@@ -183,8 +183,7 @@ func DbtConverter(taskCtx core.SubTaskContext) errors.Error
{
cmd := exec.Command(dbtExecParams[0], dbtExecParams[1:]...)
log.Info("dbt run script: ", cmd)
stdout, _ := cmd.StdoutPipe()
- err = errors.Convert(cmd.Start())
- if err != nil {
+ if err = errors.Convert(cmd.Start()); err != nil {
return err
}
// ProcessState contains information about an exited process, available
after a call to Wait.
@@ -195,7 +194,12 @@ func DbtConverter(taskCtx core.SubTaskContext)
errors.Error {
}()
// prevent zombie process
- defer cmd.Wait() //nolint
+ defer func() {
+ err := errors.Convert(cmd.Wait())
+ if err != nil {
+ log.Error(nil, "dbt run cmd.Wait() error")
+ }
+ }()
scanner := bufio.NewScanner(stdout)
var errStr string
@@ -213,6 +217,11 @@ func DbtConverter(taskCtx core.SubTaskContext)
errors.Error {
return err
}
+ // close stdout
+ if closeErr := stdout.Close(); closeErr != nil && err == nil {
+ return errors.Convert(closeErr)
+ }
+
return nil
}