You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jobs@airflow.apache.org by GitBox <gi...@apache.org> on 2026/04/27 10:26:28 UTC

[GH] (airflow/fix-fab-test-engine-leak): Workflow run "Tests" is working again!

The GitHub Actions job "Tests" on airflow.git/fix-fab-test-engine-leak has succeeded.
Run started by GitHub user potiuk (triggered by potiuk).

Head commit for run:
489fba783d5ada251596d1d35dbec075e33790bf / Jarek Potiuk <ja...@potiuk.com>
Dispose flask_sqlalchemy + airflow ORM engines in fab test fixtures

Flake on a Pendulum2 providers run ended with 8 fab test errors —
``psycopg2.OperationalError: ... FATAL: sorry, too many clients
already`` after 10031 tests had passed. Postgres' default
``max_connections=100`` was being exhausted before fab tests at the
end of the bucket could acquire a connection.

The accumulation came from fab test fixtures, not from per-test
session leaks:

- ``providers/fab/tests/unit/fab/www/views/conftest.py`` called
  ``settings.configure_orm()`` in an autouse module-scope fixture.
  ``configure_orm()`` reassigns the global engine **without** disposing
  the previous one, orphaning a pool of up to 15 pooled connections
  per call. ``settings.reconfigure_orm()`` is the helper that calls
  ``dispose_orm()`` first.
- Several fab ``app`` fixtures call ``application.create_app()``,
  which does ``db = SQLAlchemy(flask_app)`` — flask_sqlalchemy
  eagerly creates a per-app engine in ``init_app()``. None of the
  fixtures disposed those engines on teardown, so each Flask app's
  pool survived the fixture and accumulated for the worker's
  lifetime. The fab bucket is one worker that runs many such
  fixtures back-to-back.

Fixes:

- ``views/conftest.py``: switch to ``reconfigure_orm()`` (no leak on
  re-entry); dispose the flask_sqlalchemy engines on the
  module-scope ``app`` fixture teardown.
- ``www/test_auth.py``, ``views/test_views_custom_user_views.py``:
  add try/finally around the function-scope ``app`` fixture and
  dispose the flask_sqlalchemy engines per test.
- ``auth_manager/test_security.py``: dispose engines on the
  module-scope ``app`` fixture teardown.
- ``auth_manager/conftest.py``: convert the session-scope
  ``minimal_app_for_auth_api`` to ``yield`` and dispose engines on
  teardown.

A follow-up branch that bumped ``max_connections`` to 300 has been
dropped — with the leak fixed it's no longer load-bearing.

Failing run: https://github.com/apache/airflow/actions/runs/24976790617/job/73131061767

Report URL: https://github.com/apache/airflow/actions/runs/24988088318

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: jobs-unsubscribe@airflow.apache.org
For additional commands, e-mail: jobs-help@airflow.apache.org