-
Notifications
You must be signed in to change notification settings - Fork 41
Fixed Bug:- Multi-Driver Failover when one of multiple hosts down #282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| $client = new Client($driverSetupManager, $sessionConfig, $transactionConfig); | ||
|
|
||
| $this->expectException(RuntimeException::class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@p123-stack, I am missing the test where we are testing what happens during a connection exception when statements are being run.
…failure during statement execution
transistive
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost there! Good stuff. We can probably simplify some of the tests to get the same amount of coverage, and we can have a simple solution by adding reset logic to the driver setup manager
| $successfulSessionMock->method('runStatements') | ||
| ->willReturn($expectedResult); | ||
|
|
||
| $driverSetupManager->expects($this->exactly(2)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see here that this won't work perfectly. You are mocking the driver setup manager to return different drivers on subsequent calls, that is not how the driver setup manager operates. It will always return the same driver
|
|
||
| while (true) { | ||
| try { | ||
| $driver = $this->driverSetups->getDriver($this->defaultSessionConfiguration, $alias); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea here is sound, but the execution will have a bug. The driver setups will return the same driver every time. We will need to adjust the DriverSetupManager as well. Maybe we can add a reset method to the class for a specific alias, so it verifies the connections again and finds a new driver with a verified connection? If we go that route, we don't need any complex retry logic; catch the exception, reset the drivers in the driver setup manager, and try again.
Multi-Driver Failover When Primary Node Is Down
Failover Handling Implementation
Added support for failover when the highest-priority Neo4j driver is unavailable.
DriverSetupManager now continues to next available driver instead of failing immediately.
Exception Handling Improvements
Neo4jConnectionPool::acquire() now throws ConnectionPoolException instead of RuntimeException.
Neo4jDriver::verifyConnectivity() catches both ConnectException and RuntimeException.
Defensive try-catch added in DriverSetupManager::getDriver() to log and skip failed drivers.
Routing & Connectivity
Client properly attempts secondary drivers when primary fails.
Connection pool and driver retry logic updated to ensure uninterrupted operations.
Testing & Compliance
Unit tests added in MultiDriverFailoverTest and ClientExceptionHandlingTest.
Tests verify driver fallback, client-level transactions, and complete failover flow.