Skip to content

Queue automation project teardown with Oban - #6775

Draft
manelli wants to merge 1 commit into
masterfrom
playwright/faster-project-teardown
Draft

Queue automation project teardown with Oban#6775
manelli wants to merge 1 commit into
masterfrom
playwright/faster-project-teardown

Conversation

@manelli

@manelli manelli commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Moves full automation-project teardown to an asynchronous Oban job while keeping user and section cleanup synchronous.

Why this is needed

Deleting a full imported course can take several minutes. In one observed run:

  • Revision deletion took approximately 186 seconds.
  • Resource deletion took approximately 96 seconds.
  • Total project teardown took approximately 283 seconds.

The slowdown comes primarily from PostgreSQL foreign-key validation and cascading behavior. Several tables that reference revisions and resources do not have supporting indexes on their foreign-key columns.

When a revision or resource is deleted, PostgreSQL must check the referencing tables for dependent rows. Without an index, this can require sequential table scans. Since a full course contains thousands of resources, those scans may be repeated many times during teardown.

The cost therefore depends not only on the course being deleted, but also on the overall size and state of the database. As shared test tables grow, the scans become longer, causing the same Playwright test to have significantly different teardown times across runs and environments.

Waiting for this work inside the HTTP request caused request timeouts, socket hang-ups, and otherwise successful Playwright runs to report teardown warnings.

What changed

  • User, learner, educator, and section cleanup remains synchronous.
  • Full project cleanup is queued as an Oban job.
  • The original complete deletion behavior is preserved, including publications, revisions, resources, analytics records, and imported media.
  • Added a dedicated automation_teardown queue with concurrency 1 so multiple expensive teardown jobs do not overload PostgreSQL.
  • Teardown jobs are unique per project while active and retry failures up to three times.
  • Repeated execution after a project has already been deleted is treated as successful.
  • Added timing logs for the request and background project cleanup.
  • Extended the Cowboy idle timeout only for full-course imports.

@github-actions

Copy link
Copy Markdown
Contributor

Risk score: 3 → risk/low

Generated by 🚫 dangerJS against ebf6c8f

@github-actions

Copy link
Copy Markdown
Contributor

AI Review — elixir

No issues found

@github-actions

Copy link
Copy Markdown
Contributor

AI Review — performance

No issues found

@github-actions

Copy link
Copy Markdown
Contributor

AI Review — security

No issues found

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant