Skip to content

Exit asset compilation fork in start-airflow after it completed#32114

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:exit-forked-asset-commpilation
Jun 24, 2023
Merged

Exit asset compilation fork in start-airflow after it completed#32114
potiuk merged 1 commit into
apache:mainfrom
potiuk:exit-forked-asset-commpilation

Conversation

@potiuk

@potiuk potiuk commented Jun 24, 2023

Copy link
Copy Markdown
Member

The start-airflow command uses fork to start parallell asset compilation in the background so that it can happen while docker compose initializes. Unfortunately this fork child did not have sys.exit() so it returned from the function and continued to run second docker-compose in the background. In case asset compilation was not needed this could happen in parallel and both processes attempted to start two docker-compose commands in parallel.

This was not visible in "dev" mode - because asset compilation never completed there also - when asset compilation was needed, it took some time before it completed, and the effect of it were not visible, because the forked process did not get terminal output (it has been taken over by tmux by the time it started to use it) and could not grab forwarded ports, so it was running but largely invisible.

However when asset compilation was not needed, the two processes started to do the same things at the same time - so a lot of the output has been duplicated and for example the line output has been broken because the same messages were overwriting over each other and canceling the effect of EOL printed to terminal.

With this change, the forked process exits as soon as the asset compilation is completed and does not repeat the same steps that the parent process is doiing.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

The `start-airflow` command uses fork to start parallell asset
compilation in the background so that it can happen while docker
compose initializes. Unfortunately this fork child did not have
sys.exit() so it returned from the function and continued to run
second docker-compose in the background. In case asset compilation
was not needed this could happen in parallel and both processes
attempted to start two docker-compose commands in parallel.

This was not visible in "dev" mode - because asset compilation
never completed there also - when asset compilation was needed,
it took some time before it completed, and the effect of it were
not visible, because the forked process did not get terminal
output (it has been taken over by tmux by the time it started to
use it) and could not grab forwarded ports, so it was running but
largely invisible.

However when asset compilation was not needed, the two processes
started to do the same things at the same time - so a lot of
the output has been duplicated and for example the line output
has been broken because the same messages were overwriting over
each other and canceling the effect of EOL printed to terminal.

With this change, the forked process exits as soon as the
asset compilation is completed and does not repeat the same
steps that the parent process is doiing.
@potiuk

potiuk commented Jun 24, 2023

Copy link
Copy Markdown
Member Author

cc: @vandonr-amz

@potiuk potiuk merged commit 5dddf57 into apache:main Jun 24, 2023
@potiuk potiuk deleted the exit-forked-asset-commpilation branch June 24, 2023 09:04
potiuk added a commit to potiuk/airflow that referenced this pull request Jun 24, 2023
After apache#32114 the atexit registered killpg produces Permission Error in
stdout when the group was missing (basically when the asset compilation
stopped).

Changing it to ignore the error avoids the false negative appear in the
output.
potiuk added a commit that referenced this pull request Jun 24, 2023
#32116)

After #32114 the atexit registered killpg produces Permission Error in
stdout when the group was missing (basically when the asset compilation
stopped).

Changing it to ignore the error avoids the false negative appear in the
output.
ferruzzi pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 27, 2023
…he#32114)

The `start-airflow` command uses fork to start parallell asset
compilation in the background so that it can happen while docker
compose initializes. Unfortunately this fork child did not have
sys.exit() so it returned from the function and continued to run
second docker-compose in the background. In case asset compilation
was not needed this could happen in parallel and both processes
attempted to start two docker-compose commands in parallel.

This was not visible in "dev" mode - because asset compilation
never completed there also - when asset compilation was needed,
it took some time before it completed, and the effect of it were
not visible, because the forked process did not get terminal
output (it has been taken over by tmux by the time it started to
use it) and could not grab forwarded ports, so it was running but
largely invisible.

However when asset compilation was not needed, the two processes
started to do the same things at the same time - so a lot of
the output has been duplicated and for example the line output
has been broken because the same messages were overwriting over
each other and canceling the effect of EOL printed to terminal.

With this change, the forked process exits as soon as the
asset compilation is completed and does not repeat the same
steps that the parent process is doiing.
ferruzzi pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Jun 27, 2023
apache#32116)

After apache#32114 the atexit registered killpg produces Permission Error in
stdout when the group was missing (basically when the asset compilation
stopped).

Changing it to ignore the error avoids the false negative appear in the
output.
potiuk added a commit that referenced this pull request Jul 2, 2023
The `start-airflow` command uses fork to start parallell asset
compilation in the background so that it can happen while docker
compose initializes. Unfortunately this fork child did not have
sys.exit() so it returned from the function and continued to run
second docker-compose in the background. In case asset compilation
was not needed this could happen in parallel and both processes
attempted to start two docker-compose commands in parallel.

This was not visible in "dev" mode - because asset compilation
never completed there also - when asset compilation was needed,
it took some time before it completed, and the effect of it were
not visible, because the forked process did not get terminal
output (it has been taken over by tmux by the time it started to
use it) and could not grab forwarded ports, so it was running but
largely invisible.

However when asset compilation was not needed, the two processes
started to do the same things at the same time - so a lot of
the output has been duplicated and for example the line output
has been broken because the same messages were overwriting over
each other and canceling the effect of EOL printed to terminal.

With this change, the forked process exits as soon as the
asset compilation is completed and does not repeat the same
steps that the parent process is doiing.

(cherry picked from commit 5dddf57)
potiuk added a commit that referenced this pull request Jul 2, 2023
#32116)

After #32114 the atexit registered killpg produces Permission Error in
stdout when the group was missing (basically when the asset compilation
stopped).

Changing it to ignore the error avoids the false negative appear in the
output.

(cherry picked from commit 3aff742)
@potiuk potiuk added this to the Airlfow 2.6.3 milestone Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants