Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't dispose sqlalchemy engine when using internal api (std task runner) #38562

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions airflow/providers/celery/executors/celery_executor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from sqlalchemy import select

import airflow.settings as settings
from airflow.api_internal.internal_api_call import InternalApiConfig
from airflow.configuration import conf
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning, AirflowTaskTimeout
from airflow.executors.base_executor import BaseExecutor
Expand Down Expand Up @@ -155,8 +156,9 @@ def _execute_in_fork(command_to_exec: CommandType, celery_task_id: str | None =
try:
from airflow.cli.cli_parser import get_parser

settings.engine.pool.dispose()
settings.engine.dispose()
if not InternalApiConfig.get_use_internal_api():
settings.engine.pool.dispose()
settings.engine.dispose()

parser = get_parser()
# [1:] - remove "airflow" from the start of the command
Expand All @@ -166,6 +168,7 @@ def _execute_in_fork(command_to_exec: CommandType, celery_task_id: str | None =
args.external_executor_id = celery_task_id

setproctitle(f"airflow task supervisor: {command_to_exec}")
log.debug("calling func '%s' with args %s", args.func.__name__, args)
args.func(args)
ret = 0
except Exception:
Expand Down