Skip to content

AIP-51 - Single Threaded Executors #27929

Description

@o-nikolas

Overview

Some Executors, currently a subset of the local Executors, run in a single threaded fashion and have certain limitations and requirements, many of which are hardcoded. To add a new single threaded Executor would require changes to core Airflow code.
Note: This coupling often shows up with SQLite compatibility checks since it does not support multiple connections.

Examples

  • 2a) SQLite check done in configuration.py:
    is_executor_without_sqlite_support = self.get("core", "executor") not in (
    'DebugExecutor',
    'SequentialExecutor',
    )
    is_sqlite = "sqlite" in self.get('database', 'sql_alchemy_conn')
    if is_sqlite and is_executor_without_sqlite_support:
    raise AirflowConfigException(f"error: cannot use sqlite with the {self.get('core', 'executor')}")
    if is_sqlite:
  • 2b) When running in standalone mode SQLite compatibility is checked:
    if "sqlite" in conf.get("database", "sql_alchemy_conn"):
    self.print_output("standalone", "Forcing executor to SequentialExecutor")
    env["AIRFLOW__CORE__EXECUTOR"] = executor_constants.SEQUENTIAL_EXECUTOR
    else:
    self.print_output("standalone", "Forcing executor to LocalExecutor")
    env["AIRFLOW__CORE__EXECUTOR"] = executor_constants.LOCAL_EXECUTOR
  • 2c) Sensors in poke mode can block execution of DAGs when running with single process Executors, currently hardcoded to DebugExecutor (although should also include SequentialExecutor):
    if conf.get('core', 'executor') == "DebugExecutor":

Proposal

A static method or attribute on the Executor class which can be checked by core code.

There is a precedent already set with the supports_ad_hoc_ti_run attribute, see:

supports_ad_hoc_ti_run: bool = True

airflow/airflow/www/views.py

Lines 1735 to 1737 in 26f94c5

if not getattr(executor, "supports_ad_hoc_ti_run", False):
msg = "Only works with the Celery, CeleryKubernetes or Kubernetes executors"
return redirect_or_json(origin, msg, "error", 400)

Metadata

Metadata

Assignees

Labels

AIP-51AIP-51: Remove executor coupling from Core

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions