Skip to content

ProcessManager: process history not restored after a failed process, and not reset between executions #301

Closed

Description

@njoubert-cleverage

Description

ProcessManager::doExecute() saves the current ProcessHistory of the parent process and restores it only when the process succeeds: the catch block rethrows without restoring it. Symptoms:

  • when a sub-process fails and the parent goes on (process_executor task with error_strategy: skip), every later log of the parent process is tagged with the sub-process process_id / process_code / process_context (added by the log processors from ProcessManager::getProcessHistory());
  • in a long-running worker (Messenger / scheduler of the UI bundle), after a failed process, getProcessHistory() keeps returning the failed one: logs written between two processes are attributed to it. The processedIterables / processedBlockings arrays are not reset either after an exception, and ProcessManager does not implement ResetInterface (no kernel.reset tag).

Reproduction

clever_age_process:
    configurations:
        demo.subprocess_failure:
            tasks:
                start:
                    task: constant_output
                    options: { output: 'x' }
                    outputs: [sub, log]
                sub:
                    task: process_executor
                    options: { process: demo.subprocess_failure_child }
                    error_strategy: skip
                log:
                    task: logger
                    options: { level: warning, message: 'PARENT_MARKER' }
        demo.subprocess_failure_child:
            public: false
            tasks:
                fail:
                    task: constant_output
                    options: { output: 'not-a-date' }
                    outputs: [parse]
                parse:
                    task: transformer
                    options:
                        transformers:
                            date_parser: { format: 'Y-m-d' }
$ bin/console cleverage:process:execute demo.subprocess_failure
$ grep PARENT_MARKER var/log/dev.log
cleverage_process_task.WARNING: PARENT_MARKER {"input":"x"} {"process_id":1792076636.551416,"process_code":"demo.subprocess_failure_child",...,"task_code":"log",...}

Expected: "process_code":"demo.subprocess_failure" (the log task belongs to the parent process).

Tested on main (74939b2), PHP 8.5, Symfony 7.4.

Cause

ProcessManager::doExecute(): $this->processHistory = $parentProcessHistory; is after the try / catch, so it is skipped when the catch rethrows. The only consumer of ProcessManager::getProcessHistory() is AbstractProcessor::addProcessInfoToRecord().

Proposed fix

  • Restore the parent history in a finally block.
  • Implement Symfony\Contracts\Service\ResetInterface on ProcessManager (reset processHistory, processedIterables, processedBlockings) and tag the service kernel.reset, as recommended for stateful services used in long-running processes.
  • Unit test: failing sub-process caught by the parent, then getProcessHistory() returns the parent history; reset().

Found during the Symfony bundle best practices review (stateful services / kernel.reset).

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None: only the history returned by getProcessHistory() after a failure changes (it was wrong); reset() is a new method.

Activity

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