Skip to content

Commit 785f297

Browse files
author
Zhen Li
authored
Merge pull request #120 from neo4j/1.1-routing-update
Updated routing logic for no writers
2 parents 84c2e00 + b1ca5b3 commit 785f297

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

neo4j/v1/bolt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1818
# See the License for the specific language governing permissions and
1919
# limitations under the License.
20-
from neo4j.bolt import Response, RUN, PULL_ALL, ServiceUnavailable
21-
from neo4j.bolt.connection import connect, ConnectionPool, DEFAULT_PORT
20+
21+
from neo4j.bolt.connection import connect, ConnectionPool, DEFAULT_PORT, \
22+
PULL_ALL, Response, RUN, ServiceUnavailable
2223
from neo4j.compat import urlparse
2324

2425
from .api import GraphDatabase, Driver, Session, StatementResult, \

neo4j/v1/routing.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -211,15 +211,9 @@ def fetch_routing_table(self, address):
211211

212212
# No writers
213213
if num_writers == 0:
214-
if num_routers == 1:
215-
# No writers are available and only one router was returned. This
216-
# likely indicates a broken cluster so signals an error status.
217-
raise ServiceUnavailable("No write servers currently available")
218-
else:
219-
# No writers are available but multiple routers have been returned.
220-
# This likely indicates a temporary state, such as leader switching,
221-
# so we should not signal an error.
222-
return None
214+
# No writers are available. This likely indicates a temporary state,
215+
# such as leader switching, so we should not signal an error.
216+
return None
223217

224218
# At least one of each is fine, so return this table
225219
return new_routing_table

test/resources/router_no_writers_one_router.script

Lines changed: 0 additions & 8 deletions
This file was deleted.

test/test_routing.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,7 @@ def test_no_readers_should_raise_protocol_error(self):
367367
with self.assertRaises(ProtocolError):
368368
_ = pool.fetch_routing_table(address)
369369

370-
def test_no_writers_and_one_router_should_raise_signal_service_unavailable(self):
371-
with StubCluster({9001: "router_no_writers_one_router.script"}):
372-
address = ("127.0.0.1", 9001)
373-
with RoutingConnectionPool(connector) as pool:
374-
with self.assertRaises(ServiceUnavailable):
375-
_ = pool.fetch_routing_table(address)
376-
377-
def test_no_writers_and_multiple_routers_should_return_null_table(self):
370+
def test_no_writers_should_return_null_table(self):
378371
with StubCluster({9001: "router_no_writers.script"}):
379372
address = ("127.0.0.1", 9001)
380373
with RoutingConnectionPool(connector) as pool:

0 commit comments

Comments
 (0)