diff --git a/neo4j/v1/bolt.py b/neo4j/v1/bolt.py index bfdb4107f..3e9e5f761 100644 --- a/neo4j/v1/bolt.py +++ b/neo4j/v1/bolt.py @@ -17,8 +17,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from neo4j.bolt import Response, RUN, PULL_ALL, ServiceUnavailable -from neo4j.bolt.connection import connect, ConnectionPool, DEFAULT_PORT + +from neo4j.bolt.connection import connect, ConnectionPool, DEFAULT_PORT, \ + PULL_ALL, Response, RUN, ServiceUnavailable from neo4j.compat import urlparse from .api import GraphDatabase, Driver, Session, StatementResult, \ diff --git a/neo4j/v1/routing.py b/neo4j/v1/routing.py index b9583026c..b054f5bb8 100644 --- a/neo4j/v1/routing.py +++ b/neo4j/v1/routing.py @@ -211,15 +211,9 @@ def fetch_routing_table(self, address): # No writers if num_writers == 0: - if num_routers == 1: - # No writers are available and only one router was returned. This - # likely indicates a broken cluster so signals an error status. - raise ServiceUnavailable("No write servers currently available") - else: - # No writers are available but multiple routers have been returned. - # This likely indicates a temporary state, such as leader switching, - # so we should not signal an error. - return None + # No writers are available. This likely indicates a temporary state, + # such as leader switching, so we should not signal an error. + return None # At least one of each is fine, so return this table return new_routing_table diff --git a/test/resources/router_no_writers_one_router.script b/test/resources/router_no_writers_one_router.script deleted file mode 100644 index 3daa2b2c5..000000000 --- a/test/resources/router_no_writers_one_router.script +++ /dev/null @@ -1,8 +0,0 @@ -!: AUTO INIT -!: AUTO RESET - -C: RUN "CALL dbms.cluster.routing.getServers" {} - PULL_ALL -S: SUCCESS {"fields": ["ttl", "servers"]} - RECORD [300, [{"role":"ROUTE","addresses":["127.0.0.1:9001"]},{"role":"READ","addresses":["127.0.0.1:9004","127.0.0.1:9005"]},{"role":"WRITE","addresses":[]}]] - SUCCESS {} diff --git a/test/test_routing.py b/test/test_routing.py index f52a45490..b3d7be76c 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -367,14 +367,7 @@ def test_no_readers_should_raise_protocol_error(self): with self.assertRaises(ProtocolError): _ = pool.fetch_routing_table(address) - def test_no_writers_and_one_router_should_raise_signal_service_unavailable(self): - with StubCluster({9001: "router_no_writers_one_router.script"}): - address = ("127.0.0.1", 9001) - with RoutingConnectionPool(connector) as pool: - with self.assertRaises(ServiceUnavailable): - _ = pool.fetch_routing_table(address) - - def test_no_writers_and_multiple_routers_should_return_null_table(self): + def test_no_writers_should_return_null_table(self): with StubCluster({9001: "router_no_writers.script"}): address = ("127.0.0.1", 9001) with RoutingConnectionPool(connector) as pool: