@HellWalk

Как использовать доктрину после отката транзакции?

Есть воркер, который обрабатывает данные. Обработку каждой итерации нужно обернуть в транзакцию, но после отката транзакции доктрина перестает работать - "Transaction commit failed because the transaction has been marked for rollback only"

Простой тест, который эмулирует эту ошибку:

/**
     * @return void
     * @throws Exception
     */
    public function testTransaction(): void
    {
        $this->entityManager->beginTransaction();

        $this->entityManager->persist($this->createLog());
        $this->entityManager->flush();

        $this->entityManager->getConnection()->rollBack();

        $this->entityManager->beginTransaction();

        $this->entityManager->persist($this->createLog());
        $this->entityManager->flush(); // Error: Transaction commit failed because the transaction has been marked for rollback only

        $this->entityManager->getConnection()->commit();
    }


Добавление resetManager() после rollBack не помогает.
  • Вопрос задан
  • 62 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы