Repository navigation
fix #103 Reset the entity manager when a process task has closed it - #131
Merged
Merged
Conversation
Doctrine closes the entity manager after an error during a flush: the current process execution could no longer be saved nor its logs written (left started, "The EntityManager is closed."). ProcessExecutionRepository::getManaged() resets a closed entity manager (ManagerRegistry::resetManager(), reset in place), DoctrineProcessHandler::flush() does not flush a closed entity manager without logs to write. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #103 (extension: entity manager closed by a process task; the cleared case was fixed by #104)
Changes
ProcessExecutionRepository::getManaged(): a closed entity manager is reset first (ManagerRegistry::resetManager()). The entity manager service is lazy: it is reset in place, so the services holding it (repository,DoctrineProcessHandler, process tasks) get an open one, as Symfony Messenger does after a Doctrine error. New optional constructor argument?ManagerRegistry $registry = null(@doctrineinrepository.yaml), no BC break.DoctrineProcessHandler::flush(): without log to write, a closed entity manager is not flushed (it threwThe EntityManager is closed.at the end of the process); it is reset when writing the next logs or saving the execution.Tests
ProcessExecutionManagerEntityManagerTest::testEntityManagerClosedDuringTheProcess(entity manager of the test application): log,close(), log, end of the process: a singlefinishexecution with its report, context and both logs; the entity manager service is open again (same instance).DoctrineProcessHandlerTest: closed entity manager without records: no flush; open one: flushed as before.Checked in process-bundle-demo (MySQL, doctrine-bundle 3.3, PHP 8.5, Symfony 7.4)
demo.ui.entity_manager_closed: log,DoctrineWriterTaskwriting anAuthorwith a 300 characters last name (Data too long, entity manager closed by Doctrine),error_strategy: skip.started, no end dateCritical process failure:The EntityManager is closed.finishexecuted successfullyWith
error_strategy: stop: a singlefailedexecution with its 8 logs.🤖 Generated with Claude Code