You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by bo...@apache.org on 2016/12/29 16:16:37 UTC

[1/3] incubator-airflow git commit: [AIRFLOW-721] Descendant process can disappear before termination

Repository: incubator-airflow
Updated Branches:
  refs/heads/master f048e94c8 -> 75c3e1d29


[AIRFLOW-721] Descendant process can disappear before termination

There is a race condition in helpers.py's kill_descendant_processes
that checks for running processes and then tries to terminate them.
This is not done atomically allowing for a small window where a PID
can disappear before termination.


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/b95a6154
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/b95a6154
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/b95a6154

Branch: refs/heads/master
Commit: b95a615496a102eccb4e310792e5080bb29db71b
Parents: ed8e15b
Author: Bolke de Bruin <bo...@xs4all.nl>
Authored: Tue Dec 27 21:03:39 2016 +0100
Committer: Bolke de Bruin <bo...@Bolkes-MacBook-Pro.local>
Committed: Thu Dec 29 15:58:18 2016 +0100

----------------------------------------------------------------------
 airflow/utils/helpers.py | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/b95a6154/airflow/utils/helpers.py
----------------------------------------------------------------------
diff --git a/airflow/utils/helpers.py b/airflow/utils/helpers.py
index 24fc310..23fda03 100644
--- a/airflow/utils/helpers.py
+++ b/airflow/utils/helpers.py
@@ -205,10 +205,16 @@ def kill_descendant_processes(logger, pids_to_kill=None):
     logger.warn("Terminating descendant processes of {} PID: {}"
                 .format(this_process.cmdline(),
                         this_process.pid))
-    for descendant in descendant_processes:
+
+    temp_processes = descendant_processes[:]
+    for descendant in temp_processes:
         logger.warn("Terminating descendant process {} PID: {}"
                     .format(descendant.cmdline(), descendant.pid))
-        descendant.terminate()
+        try:
+            descendant.terminate()
+        except psutil.NoSuchProcess:
+            descendant_processes.remove(descendant)
+
     logger.warn("Waiting up to {}s for processes to exit..."
                 .format(TIME_TO_WAIT_AFTER_SIGTERM))
     try:
@@ -228,8 +234,11 @@ def kill_descendant_processes(logger, pids_to_kill=None):
         for descendant in descendant_processes:
             logger.warn("Killing descendant process {} PID: {}"
                         .format(descendant.cmdline(), descendant.pid))
-            descendant.kill()
-            descendant.wait()
+            try:
+                descendant.kill()
+                descendant.wait()
+            except psutil.NoSuchProcess:
+                pass
         logger.warn("Killed all descendant processes of {} PID: {}"
                     .format(this_process.cmdline(),
                             this_process.pid))


[2/3] incubator-airflow git commit: Log needs to be part of try/catch block

Posted by bo...@apache.org.
Log needs to be part of try/catch block


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/9de7762d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/9de7762d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/9de7762d

Branch: refs/heads/master
Commit: 9de7762d468378014c7221e8e2fabffe88fd9abc
Parents: b95a615
Author: Bolke de Bruin <bo...@Bolkes-MacBook-Pro.local>
Authored: Thu Dec 29 16:52:31 2016 +0100
Committer: Bolke de Bruin <bo...@Bolkes-MacBook-Pro.local>
Committed: Thu Dec 29 16:52:31 2016 +0100

----------------------------------------------------------------------
 airflow/utils/helpers.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/9de7762d/airflow/utils/helpers.py
----------------------------------------------------------------------
diff --git a/airflow/utils/helpers.py b/airflow/utils/helpers.py
index 23fda03..6bd7a64 100644
--- a/airflow/utils/helpers.py
+++ b/airflow/utils/helpers.py
@@ -208,9 +208,9 @@ def kill_descendant_processes(logger, pids_to_kill=None):
 
     temp_processes = descendant_processes[:]
     for descendant in temp_processes:
-        logger.warn("Terminating descendant process {} PID: {}"
-                    .format(descendant.cmdline(), descendant.pid))
         try:
+            logger.warn("Terminating descendant process {} PID: {}"
+                        .format(descendant.cmdline(), descendant.pid))
             descendant.terminate()
         except psutil.NoSuchProcess:
             descendant_processes.remove(descendant)


[3/3] incubator-airflow git commit: Merge branch 'AIRFLOW-721'

Posted by bo...@apache.org.
Merge branch 'AIRFLOW-721'


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/75c3e1d2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/75c3e1d2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/75c3e1d2

Branch: refs/heads/master
Commit: 75c3e1d29b3d00d1b8fb8764f9a952b444d4ae61
Parents: f048e94 9de7762
Author: Bolke de Bruin <bo...@xs4all.nl>
Authored: Thu Dec 29 17:16:29 2016 +0100
Committer: Bolke de Bruin <bo...@xs4all.nl>
Committed: Thu Dec 29 17:16:29 2016 +0100

----------------------------------------------------------------------
 airflow/utils/helpers.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------