Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions neo4j/v1/bolt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down
12 changes: 3 additions & 9 deletions neo4j/v1/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions test/resources/router_no_writers_one_router.script

This file was deleted.

9 changes: 1 addition & 8 deletions test/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down