You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/04/29 15:10:07 UTC
[jira] [Commented] (AIRFLOW-6529) Serialization error occurs when
the scheduler tries to run on macOS.
[ https://issues.apache.org/jira/browse/AIRFLOW-6529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17095534#comment-17095534 ]
ASF GitHub Bot commented on AIRFLOW-6529:
-----------------------------------------
jhtimmins commented on a change in pull request #7128:
URL: https://github.com/apache/airflow/pull/7128#discussion_r417022066
##########
File path: tests/utils/test_dag_processing.py
##########
@@ -131,10 +131,47 @@ def __enter__(self):
def __exit__(self, *exc_info):
# shutil.rmtree(self.settings_root)
# Reset config
+
conf.set('logging', 'logging_config_class', '')
sys.path.remove(self.settings_root)
+class FakeDagFileProcessorRunner(DagFileProcessorProcess):
+ # This fake processor will return the zombies it received in constructor
+ # as its processing result w/o actually parsing anything.
+ def __init__(self, file_path, pickle_dags, dag_id_white_list, zombies):
+ super().__init__(file_path, pickle_dags, dag_id_white_list, zombies)
+ self._result = zombies, 0
+
+ def start(self):
+ pass
+
+ @property
+ def start_time(self):
+ return DEFAULT_DATE
+
+ @property
+ def pid(self):
+ return 1234
+
+ @property
+ def done(self):
+ return True
+
+ @property
+ def result(self):
+ return self._result
+
+
+def fake_dag_file_processor_factory(file_path, zombies, dag_ids, pickle_dags):
Review comment:
For clarity, it might be worth keeping the argument order consistent. So the preceding line would be:
`def fake_dag_file_processor_factory(file_path, pickle_dags, dag_ids, zombies):`
##########
File path: tests/utils/test_dag_processing.py
##########
@@ -131,10 +131,47 @@ def __enter__(self):
def __exit__(self, *exc_info):
# shutil.rmtree(self.settings_root)
# Reset config
+
conf.set('logging', 'logging_config_class', '')
sys.path.remove(self.settings_root)
+class FakeDagFileProcessorRunner(DagFileProcessorProcess):
+ # This fake processor will return the zombies it received in constructor
+ # as its processing result w/o actually parsing anything.
+ def __init__(self, file_path, pickle_dags, dag_id_white_list, zombies):
+ super().__init__(file_path, pickle_dags, dag_id_white_list, zombies)
+ self._result = zombies, 0
Review comment:
Might be worth defining the zero to provide some context for what it represents.
##########
File path: airflow/utils/dag_processing.py
##########
@@ -332,8 +340,20 @@ def start(self):
"""
Launch DagFileProcessorManager processor and start DAG parsing loop in manager.
"""
- self._parent_signal_conn, child_signal_conn = multiprocessing.Pipe()
- self._process = multiprocessing.Process(
+ if conf.has_option('core', 'mp_start_method'):
+ mp_start_method = conf.get('core', 'mp_start_method')
+ else:
+ mp_start_method = mp.get_start_method()
+
+ possible_value_list = mp.get_all_start_methods()
+ if mp_start_method not in possible_value_list:
+ raise AirflowConfigException(
+ "mp_start_method should not be " + mp_start_method +
+ ". Possible value is one of " + str(possible_value_list))
+ cxt = mp.get_context(mp_start_method)
+
+ self._parent_signal_conn, child_signal_conn = cxt.Pipe()
+ self._process = cxt.Process(
Review comment:
It looks like this block of code is identical to https://github.com/apache/airflow/pull/7128/files#diff-c35269bcfbbe386e269ffa7487e86192R171-R184. Given that they would probably need to change at the same time if either ever changed, this might be a good case for a utility mixin. Lines 343-352 could go into a MultiProcessingConfigMixin class or similar.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
> Serialization error occurs when the scheduler tries to run on macOS.
> --------------------------------------------------------------------
>
> Key: AIRFLOW-6529
> URL: https://issues.apache.org/jira/browse/AIRFLOW-6529
> Project: Apache Airflow
> Issue Type: Bug
> Components: scheduler
> Affects Versions: 1.10.8
> Environment: macOS
> Python 3.8
> multiprocessing with spawn mode
> Reporter: Kousuke Saruta
> Assignee: Kousuke Saruta
> Priority: Major
>
> When we try to run the scheduler on macOS, we will get a serialization error like as follows.
> {code}
> ____________ _____________
> ____ |__( )_________ __/__ /________ __
> ____ /| |_ /__ ___/_ /_ __ /_ __ \_ | /| / /
> ___ ___ | / _ / _ __/ _ / / /_/ /_ |/ |/ /
> _/_/ |_/_/ /_/ /_/ /_/ \____/____/|__/
> [2020-01-10 19:54:41,974] {executor_loader.py:59} INFO - Using executor SequentialExecutor
> [2020-01-10 19:54:41,983] {scheduler_job.py:1462} INFO - Starting the scheduler
> [2020-01-10 19:54:41,984] {scheduler_job.py:1469} INFO - Processing each file at most -1 times
> [2020-01-10 19:54:41,984] {scheduler_job.py:1472} INFO - Searching for files in /Users/sarutak/airflow/dags
> [2020-01-10 19:54:42,025] {scheduler_job.py:1474} INFO - There are 27 files in /Users/sarutak/airflow/dags
> [2020-01-10 19:54:42,025] {scheduler_job.py:1527} INFO - Resetting orphaned tasks for active dag runs
> [2020-01-10 19:54:42,059] {scheduler_job.py:1500} ERROR - Exception when executing execute_helper
> Traceback (most recent call last):
> File "/Users/sarutak/work/oss/airflow-env/master-python3.8.1/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 1498, in _execute
> self._execute_helper()
> File "/Users/sarutak/work/oss/airflow-env/master-python3.8.1/lib/python3.8/site-packages/airflow/jobs/scheduler_job.py", line 1531, in _execute_helper
> self.processor_agent.start()
> File "/Users/sarutak/work/oss/airflow-env/master-python3.8.1/lib/python3.8/site-packages/airflow/utils/dag_processing.py", line 348, in start
> self._process.start()
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/process.py", line 121, in start
> self._popen = self._Popen(self)
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/context.py", line 224, in _Popen
> return _default_context.get_context().Process._Popen(process_obj)
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/context.py", line 283, in _Popen
> return Popen(process_obj)
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 32, in __init__
> super().__init__(process_obj)
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/popen_fork.py", line 19, in __init__
> self._launch(process_obj)
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/popen_spawn_posix.py", line 47, in _launch
> reduction.dump(process_obj, fp)
> File "/opt/python/3.8.1/lib/python3.8/multiprocessing/reduction.py", line 60, in dump
> ForkingPickler(file, protocol).dump(obj)
> AttributeError: Can't pickle local object 'SchedulerJob._execute.<locals>.processor_factory'
> {code}
> The reason is scheduler try to run subprocesses using multiprocessing with spawn mode and the mode tries to pickle objects. In this case, `processor_factory` inner method is tried to be pickled.
> Actually, as of Python 3.8, spawn mode is the default mode in macOS.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)