Skip to content

The tasks are not finalized when the process fails: resources left open in a long-running worker #373

Closed

Description

@njoubert-cleverage

FinalizableTaskInterface::finalize() is never called when a process fails: ProcessManager::doExecute() finalizes the tasks only after a successful resolution, the catch does not.

The resources opened by the tasks stay open in a long-running worker (Messenger, UI bundle): file handles of the CSV, JSON stream, XML and line readers / writers, and the cursor of doctrine_database_reader. With MySQL unbuffered queries, every next execution of the worker then fails (2014 Cannot execute queries while other unbuffered queries are active), including unrelated processes and the writes of the UI bundle in process_execution.

Fix: when the process fails, finalize every initialized task, each one in its own try/catch (a finalization failure is logged and does not hide the original error). This changes the contract of finalize(), to document: it is called whether the process succeeds or fails (e.g. StatCounterTask also logs its count on failure).

Found during the audit v3 (audit-v3-angles.md #177).

Activity

  1. added a commit that references this issue on Oct 23, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions