PHP Doctrine with SQL Server Always On #5570

Closed
opened 2026-01-22 15:11:36 +01:00 by admin · 4 comments
Owner

Originally created by @fabionvs on GitHub (Jun 7, 2017).

Originally assigned to: @Ocramius on GitHub.

Hello,
I am developing an application using Symfony 3 (php 7.1) with SQL Server database with AlwaysOn. AlwaysOn is a SQL server support for high-availability and disaster recovery, and Doctrine 2 is not working well with this paradigm.

I've developed a CRUD to test it for the infrastructure section at my job that implemented this database. At the first time, it was working correctly and persisting ok. Although, when they change the database for other one, like when happens if the first one stops working, automatically go to the other database with the same structure. When it happens I receive an error message from doctrine:

Fatal error: Invalid handle returned. in C:\xampp\htdocs\testesql\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 43

It looks like Doctrine caches something that is not working with this paradigm of database. I am using Microsoft SQL Server driver (pdo_sqlsrv). Could someone help me? I would be glad.

Originally created by @fabionvs on GitHub (Jun 7, 2017). Originally assigned to: @Ocramius on GitHub. Hello, I am developing an application using Symfony 3 (php 7.1) with SQL Server database with AlwaysOn. AlwaysOn is a SQL server support for high-availability and disaster recovery, and Doctrine 2 is not working well with this paradigm. I've developed a CRUD to test it for the infrastructure section at my job that implemented this database. At the first time, it was working correctly and persisting ok. Although, when they change the database for other one, like when happens if the first one stops working, automatically go to the other database with the same structure. When it happens I receive an error message from doctrine: > Fatal error: Invalid handle returned. in C:\xampp\htdocs\testesql\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 43 It looks like Doctrine caches something that is not working with this paradigm of database. I am using Microsoft SQL Server driver (pdo_sqlsrv). Could someone help me? I would be glad.
admin added the Can't Fix label 2026-01-22 15:11:36 +01:00
admin closed this issue 2026-01-22 15:11:36 +01:00
Author
Owner

@Ocramius commented on GitHub (Jun 7, 2017):

@fabionvs any way to reproduce this? What are you passing to the connection?

when they change the database for other one, like when happens if the first one stops working, automatically go to the other database with the same structure. When it happens I receive an error message from doctrine:

I can't understand the wording in this bit: can you rephrase it?

@Ocramius commented on GitHub (Jun 7, 2017): @fabionvs any way to reproduce this? What are you passing to the connection? > when they change the database for other one, like when happens if the first one stops working, automatically go to the other database with the same structure. When it happens I receive an error message from doctrine: I can't understand the wording in this bit: can you rephrase it?
Author
Owner

@fabionvs commented on GitHub (Jun 7, 2017):

Hello @Ocramius, thank you for your help!
The SQL Server database was implemented in a cluster. And, when the main instance stops working, or if they change the instance, it goes to another backup instance while using the same connection. And, for testing propourses they changed the instance to see if the application still works, but is not working and I receive that message:

Fatal error: Invalid handle returned. in C:\xampp\htdocs\testesql\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 43

At StackOverflow, I've got a nice answer that I don't tested if really works:

There are suggestions to try ConnectionPooling=0 while using pdo_sqlsrv. Doctrines documentation even states that there are issues with their tests while using pdo_sqlsrv. docs.doctrine-project.org/projects/doctrine-dbal/en/latest/… . I haven't tried using pdo_sqlsrv in great depth before, so not sure if this is answer worthy.

@fabionvs commented on GitHub (Jun 7, 2017): Hello @Ocramius, thank you for your help! The SQL Server database was implemented in a cluster. And, when the main instance stops working, or if they change the instance, it goes to another backup instance while using the same connection. And, for testing propourses they changed the instance to see if the application still works, but is not working and I receive that message: > Fatal error: Invalid handle returned. in C:\xampp\htdocs\testesql\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOConnection.php on line 43 At StackOverflow, I've got a nice answer that I don't tested if really works: > There are suggestions to try ConnectionPooling=0 while using pdo_sqlsrv. Doctrines documentation even states that there are issues with their tests while using pdo_sqlsrv. docs.doctrine-project.org/projects/doctrine-dbal/en/latest/… . I haven't tried using pdo_sqlsrv in great depth before, so not sure if this is answer worthy.
Author
Owner

@Ocramius commented on GitHub (Jun 7, 2017):

That's most likely something that needs fixing within pdo_sqlsrv, not in doctrine, sorry :-\

Closing as can't fix here.

@Ocramius commented on GitHub (Jun 7, 2017): That's most likely something that needs fixing within `pdo_sqlsrv`, not in doctrine, sorry :-\ Closing as `can't fix` here.
Author
Owner

@Ocramius commented on GitHub (Jun 7, 2017):

Note: removed the Bug label because this is a pdo_sqlsrv issue that isn't a bug in doctrine itself.

@Ocramius commented on GitHub (Jun 7, 2017): Note: removed the `Bug` label because this is a `pdo_sqlsrv` issue that isn't a bug in doctrine itself.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5570