Skip to content

Prevent new setup-time database pre-cleaning in unit tests - #71589

Closed
shivaam wants to merge 2 commits into
apache:mainfrom
shivaam:issue-71577-db-isolation-slice-1
Closed

shivaam wants to merge 2 commits into
apache:mainfrom
shivaam:issue-71577-db-isolation-slice-1

Conversation

@shivaam

@shivaam shivaam commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Unit tests sometimes call clear_db_*() during setup. This can hide database rows leaked by an earlier test instead of fixing the fixture that created them.

This PR adds a small prek check that:

  • detects direct clear_db_* calls in pytest fixture setup and xUnit setup methods;
  • blocks new affected files;
  • temporarily allows the 79 existing affected files;
  • removes a file from the allowlist once its cleanup calls are fixed;
  • prevents removed files from being added back.

Existing allowlisted files are exempt as a whole. This keeps the first version simple and avoids failures caused by line movement. Future PRs can fix those files incrementally.

When the check fails, it explains that the fixture or test creating the rows must clean them during teardown and links to #71577.

This changes test tooling only. It does not change Airflow runtime behavior.

Related: #71577

Validation:

  • 978 prek tests passed
  • full-repository checker passed
  • current-main baseline simulation passed
  • formatting, mypy, hook-registration, and commit checks passed

Was generative AI tooling used to co-author this PR?
  • Yes — OpenAI Codex

Generated-by: OpenAI Codex

@shivaam
shivaam force-pushed the issue-71577-db-isolation-slice-1 branch from ca4dfc9 to fc7609f Compare August 15, 2026 00:00
Avoid CI failures when existing cleanup calls move within a temporarily grandfathered test file.
@shivaam
shivaam force-pushed the issue-71577-db-isolation-slice-1 branch from fc7609f to 038cd86 Compare August 15, 2026 00:04
@shivaam
shivaam marked this pull request as ready for review August 15, 2026 00:09
@jroachgolf84

Copy link
Copy Markdown
Collaborator

@shivaam - after this PR is merged, what would be the next-steps/additional changes needed?

@jroachgolf84

Copy link
Copy Markdown
Collaborator

I assume it would be the list here?

generated/known_clear_db_setup.txt

@shivaam

shivaam commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Yes, broadly. generated/known_clear_db_setup.txt is the migration list for the patterns this guard detects. It contains one entry per affected file, not per cleanup call.

Follow-up PRs can take small groups from that list, fix cleanup in the fixture or test that owns the rows, and remove the setup-time clear_db_* calls. Once a file has no remaining detected calls, regenerating the list removes it, and the guard prevents it from being added back.

We’re also experimenting separately with a runtime detector and the dag_maker asset cleanup gap. Those may help prioritize later work, but they aren’t part of this PR or committed next steps yet.

@potiuk potiuk added the closed because of open PR limit Closed as a one-time step of introducing the open pull request limit label Sep 25, 2026
@potiuk

potiuk commented Sep 25, 2026

Copy link
Copy Markdown
Member

Hello @shivaam - thank you for your contributions to Apache Airflow!

The Airflow community has introduced a limit of 5 open pull requests at a time for contributors without write access to the repository. You currently have 6 open pull requests, so - as a one-time step of introducing the limit - we closed the ones where maintainers have not engaged yet:

These pull requests stay open because maintainers are already engaged in them - they count towards your limit:

This is not a judgement of you or of your changes. We never told contributors before that opening many pull requests at once was a problem, so there is nothing to feel bad about - and nothing is lost: your branches, commits and the review history stay where they are.

What we ask you to do is to make your first prioritization decision: choose which of the pull requests above matter most to you, and reopen them (up to 5 open at a time, including the ones still open) with the "Reopen pull request" button or gh pr reopen <PR_NUMBER> --repo apache/airflow. Reopen the ones you are ready to follow through - keep them rebased, respond to review comments and fix failing checks.

While your pull requests are waiting for review, the most valuable thing you can do is help in other ways - reviewing other contributors' pull requests, helping with issues, and taking part in the discussions on the devlist and Slack.

Why we introduced the limit, what it means for you and how to reopen or restore a pull request is explained in https://github.com/apache/airflow/blob/main/contributing-docs/32_open_pull_request_limit.rst.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

@potiuk potiuk closed this Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:dev-tools closed because of open PR limit Closed as a one-time step of introducing the open pull request limit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants