New transaction is not allowed because there are other threads running in the session #6088

Closed
opened 2026-01-22 15:26:35 +01:00 by admin · 6 comments
Owner

Originally created by @martinpfeiferdev on GitHub (Oct 29, 2018).

Hello, I'm trying to run a procedure, and then an update to a table, however the following error occurs: "New transaction is not allowed because there are other threads running in the session", follow the code below:

`

public function update(TestEntity $testEntity) {
    $sql = "EXEC TEST_PROC 1, 1";

    $entityManager = $this->getEntityManager();
    $stmt = $entityManager->getConnection()->prepare($sql);

    if ($stmt->execute ()) {
        $this->getEntityManager()->merge($testEntity);
        $this->getEntityManager()->flush();
    }
}

`

Any suggestions and / or solutions?

Originally created by @martinpfeiferdev on GitHub (Oct 29, 2018). Hello, I'm trying to run a procedure, and then an update to a table, however the following error occurs: "New transaction is not allowed because there are other threads running in the session", follow the code below: ` public function update(TestEntity $testEntity) { $sql = "EXEC TEST_PROC 1, 1"; $entityManager = $this->getEntityManager(); $stmt = $entityManager->getConnection()->prepare($sql); if ($stmt->execute ()) { $this->getEntityManager()->merge($testEntity); $this->getEntityManager()->flush(); } } ` Any suggestions and / or solutions?
admin added the Question label 2026-01-22 15:26:35 +01:00
admin closed this issue 2026-01-22 15:26:35 +01:00
Author
Owner

@Ocramius commented on GitHub (Oct 30, 2018):

New transaction is not allowed because there are other threads running in the session

What's the RDBMS? Nested transactions are quite normal in ORM context.

@Ocramius commented on GitHub (Oct 30, 2018): > New transaction is not allowed because there are other threads running in the session What's the RDBMS? Nested transactions are quite normal in ORM context.
Author
Owner

@martinpfeiferdev commented on GitHub (Oct 30, 2018):

@Ocramius RDBMS is SQL server 2012 and framework Symfony 3.4.

@martinpfeiferdev commented on GitHub (Oct 30, 2018): @Ocramius RDBMS is SQL server 2012 and framework Symfony 3.4.
Author
Owner

@Ocramius commented on GitHub (Oct 30, 2018):

Googled a bit, and this may be because the same PHP process has a second
open DB connection. Not really a DBAL or ORM issue: seems more like one of
the usual "SQL server being special" issues...

On Tue, 30 Oct 2018, 13:49 Martin Pfeifer, notifications@github.com wrote:

@Ocramius https://github.com/Ocramius RDBMS is SQL server 2012 and
framework Symfony 3.4.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7446#issuecomment-434286753,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakOHihgSgA6fDDAdQ4ArzQe9UHm4tks5uqErbgaJpZM4YA5uC
.

@Ocramius commented on GitHub (Oct 30, 2018): Googled a bit, and this may be because the same PHP process has a second open DB connection. Not really a DBAL or ORM issue: seems more like one of the usual "SQL server being special" issues... On Tue, 30 Oct 2018, 13:49 Martin Pfeifer, <notifications@github.com> wrote: > @Ocramius <https://github.com/Ocramius> RDBMS is SQL server 2012 and > framework Symfony 3.4. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7446#issuecomment-434286753>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakOHihgSgA6fDDAdQ4ArzQe9UHm4tks5uqErbgaJpZM4YA5uC> > . >
Author
Owner

@martinpfeiferdev commented on GitHub (Oct 31, 2018):

@Ocramius
I agree with you, but do you have any solutions and / or suggestions for this case?

@martinpfeiferdev commented on GitHub (Oct 31, 2018): @Ocramius I agree with you, but do you have any solutions and / or suggestions for this case?
Author
Owner

@Ocramius commented on GitHub (Oct 31, 2018):

Look for the second connection: this is not a bug in this tooling.

On Wed, 31 Oct 2018, 01:18 Martin Pfeifer <notifications@github.com wrote:

@Ocramius https://github.com/Ocramius
I agree with you, but do you have any solutions and / or suggestions for
this case?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/doctrine/doctrine2/issues/7446#issuecomment-434517183,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAJakOhG8icJQI1L5uRL6SMQlCGb5ve2ks5uqOxNgaJpZM4YA5uC
.

@Ocramius commented on GitHub (Oct 31, 2018): Look for the second connection: this is not a bug in this tooling. On Wed, 31 Oct 2018, 01:18 Martin Pfeifer <notifications@github.com wrote: > @Ocramius <https://github.com/Ocramius> > I agree with you, but do you have any solutions and / or suggestions for > this case? > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/doctrine2/issues/7446#issuecomment-434517183>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AAJakOhG8icJQI1L5uRL6SMQlCGb5ve2ks5uqOxNgaJpZM4YA5uC> > . >
Author
Owner

@martinpfeiferdev commented on GitHub (Nov 3, 2018):

@Ocramius
I solved it as follows, follow the code below:

`

public function update(TestEntity $testEntity) {
$sql = "EXEC TEST_PROC 1, 1";

$entityManager = $this->getEntityManager();
$stmt = $entityManager->getConnection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();

$entityManager->merge($testEntity);
$entityManager->flush();

}

`

@martinpfeiferdev commented on GitHub (Nov 3, 2018): @Ocramius I solved it as follows, follow the code below: ` public function update(TestEntity $testEntity) { $sql = "EXEC TEST_PROC 1, 1"; $entityManager = $this->getEntityManager(); $stmt = $entityManager->getConnection()->prepare($sql); $stmt->execute(); $stmt->closeCursor(); $entityManager->merge($testEntity); $entityManager->flush(); } `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6088