Skip to content

Commit

Permalink
Fix IntegrityError during webserver startup (#27297)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8f99c79)
  • Loading branch information
ephraimbuddy committed Nov 9, 2022
1 parent 51194c7 commit 6515eb9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions airflow/cli/commands/webserver_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ def webserver(args):

run_args += ["airflow.www.app:cached_app()"]

# To prevent different workers creating the web app and
# all writing to the database at the same time, we use the --preload option.
# With the preload option, the app is loaded before the workers are forked, and each worker will
# then have a copy of the app
run_args += ['--preload']

gunicorn_master_proc = None

def kill_proc(signum, _):
Expand Down
1 change: 1 addition & 0 deletions tests/cli/commands/test_webserver_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ def test_cli_webserver_args(self):
'--access-logformat',
'custom_log_format',
'airflow.www.app:cached_app()',
"--preload",
],
close_fds=True,
)

0 comments on commit 6515eb9

Please sign in to comment.