Skip to content

Commit 9f57ba4

Browse files
committed
accounted for non existing routing table in version 3.5
1 parent 66722e9 commit 9f57ba4

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/Neo4j/Neo4jConnectionPool.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use function array_slice;
1717
use function array_unique;
18+
use Bolt\error\MessageException;
1819
use Bolt\protocol\V3;
1920
use Bolt\protocol\V4;
2021
use Bolt\protocol\V4_3;
@@ -30,6 +31,7 @@
3031
use Laudis\Neo4j\Databags\SessionConfiguration;
3132
use Laudis\Neo4j\Enum\AccessMode;
3233
use Laudis\Neo4j\Enum\RoutingRoles;
34+
use const PHP_INT_MAX;
3335
use Psr\Http\Message\UriInterface;
3436
use function random_int;
3537
use function str_starts_with;
@@ -128,7 +130,7 @@ private function routingTable(ConnectionInterface $connection, SessionConfigurat
128130
return $this->useRoutingTable($bolt);
129131
}
130132

131-
return $this->useClusterOverview($bolt);
133+
return $this->useClusterOverview($bolt, $connection);
132134
}
133135

134136
private function useRouteMessage(V4_3 $bolt, SessionConfiguration $config): RoutingTable
@@ -172,9 +174,22 @@ private function useRoutingTable(V4 $bolt): RoutingTable
172174
/**
173175
* @throws Exception
174176
*/
175-
private function useClusterOverview(V3 $bolt): RoutingTable
177+
private function useClusterOverview(V3 $bolt, ConnectionInterface $c): RoutingTable
176178
{
177-
$bolt->run('CALL dbms.cluster.overview()');
179+
try {
180+
$bolt->run('CALL dbms.cluster.overview()');
181+
} catch (MessageException $e) {
182+
return new RoutingTable([
183+
[
184+
'addresses' => [(string) $c->getServerAddress()],
185+
'role' => 'WRITE',
186+
],
187+
[
188+
'addresses' => [(string) $c->getServerAddress()],
189+
'role' => 'READ',
190+
],
191+
], PHP_INT_MAX);
192+
}
178193
/** @var list<array{0: string, 1: list<string>, 2: string, 4: list, 4:string}> */
179194
$response = $bolt->pullAll();
180195
$response = array_slice($response, 0, count($response) - 1);

0 commit comments

Comments
 (0)