its-amann commented on code in PR #77020:
URL: https://github.com/apache/airflow/pull/77020#discussion_r4577328052
##########
task-sdk/src/airflow/sdk/execution_time/supervisor.py:
##########
@@ -1696,8 +1698,14 @@ def start( # type: ignore[override]
# Tests override `target` with a local stub to exercise the base
# infrastructure; keep bare fork for those.
use_exec = target is _subprocess_main and task_process_uses_exec()
- if target is _subprocess_main and not use_exec:
+ gc_frozen = target is _subprocess_main and not use_exec
+ if gc_frozen:
_import_task_runner_before_fork()
+ # A GC pass in either process writes to the headers of the objects
the task process
+ # inherits, which splits the pages both processes share
copy-on-write. ``wait()``
+ # unfreezes once the task process exits, so a worker that
supervises many tasks in one
+ # process collects these objects again between tasks.
+ gc.freeze()
proc: Self = super().start(
Review Comment:
if `super().start()` or `_on_child_started` raises here (fork fails, or the
ti start call errors and the child gets SIGKILLed), no caller ever gets a proc
to `wait()` on, so the GC stays frozen in that worker until some later task
happens to finish
```diff
- proc: Self = super().start(
- ...
- )
- proc._gc_frozen = gc_frozen
- proc._on_child_started(...)
+ try:
+ proc: Self = super().start(
+ ...
+ )
+ proc._gc_frozen = gc_frozen
+ proc._on_child_started(...)
+ except BaseException:
+ # No caller gets a proc to ``wait()`` on, so nothing else would
unfreeze the GC.
+ if gc_frozen:
+ gc.unfreeze()
+ raise
return proc
```
fixed this plus a test in this commit, you can just cherry pick it instead
of redoing it:
https://github.com/its-amann/airflow/commit/a080842be2e6cb3f32a051f9d95c00c7410df13d
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]