Skip to content

The triggerer runs its database loop again every time the trigger runner logs a line #77061

Open

Description

@seanghaeli

TriggerRunnerSupervisor.run_once (airflow-core/src/airflow/jobs/triggerer_job_runner.py) waits for the trigger runner with self._service_subprocess(1), which returns as soon as any of the runner's sockets has data, and then does a full pass of database work: load_triggers (Trigger.assign_unassigned and Trigger.ids_for_triggerer), clean_unused and the heartbeat check. The runner's log socket is in the same selector, so every line a trigger logs starts another pass. Requests from the runner, like connection and variable lookups, do the same.

Measured on main (a81cfb7) in Breeze with Postgres, the real triggerer job and one asset watcher that logs N lines a second (mean of 2 runs):

Trigger logs Loop passes/s SQL statements/s Row-locking statements/s
nothing 1.0 7.5 4
10 lines/s 11.0 77.5 44
50 lines/s 51.0 357.6 204
200 lines/s 107.6 753.9 430.5

Every pass is the same 7 statements, 4 of them row-locking (the three claim queries and the clean_unused select), so a triggerer's database load grows with how much its triggers log, not with how many triggers it runs.

Suggestion: keep reading the runner's sockets as data arrives, but run the database part of the loop on a timer, about once a second, which is how often the runner syncs its state anyway.

Done when: a triggerer's database passes stay at about one a second however much its triggers log, while log lines and runner requests are still handled as they arrive, with a test.

Related to the triggerer performance work in #76209: syncing the runner more often would wake this loop the same way.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions