-
Notifications
You must be signed in to change notification settings - Fork 199
Do not purge inUse connections #197
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
Conversation
b1cd45c
to
0abb9f8
Compare
neo4j/v1/routing.py
Outdated
@@ -140,6 +143,9 @@ def update(self, new_routing_table): | |||
self.last_updated_time = self.timer() | |||
self.ttl = new_routing_table.ttl | |||
|
|||
def servers(self): | |||
return set(self.routers.elements() + self.writers.elements() + self.readers.elements()) |
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.
This can just be return set(self.routers) | set(self.writers) | set(self.readers)
and there is no need to add an elements
accessor on OrderedSet
.
neo4j/v1/routing.py
Outdated
@@ -81,6 +81,9 @@ def replace(self, elements=()): | |||
e.clear() | |||
e.update(OrderedDict.fromkeys(elements)) | |||
|
|||
def elements(self): | |||
return list(self._elements) |
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.
Not needed - see below.
neo4j/bolt/connection.py
Outdated
conn.close() | ||
except IOError: | ||
pass | ||
if len(connections) == 0: |
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.
if not connections
…outing table is available Instead we deactive the server (a.k.a. closing all idle connections) in connection pool. When an connection failure happens, the connection server will be removed from the routing table and all idle connections with this server will be closed in the connection pool. When a new routing table is available, all idle connections towards the servers that are not in the new routing table will be removed. If the server has no inUse connections, then this server will also be totally removed from the connection pool. Note: there is no extra protection to against `acquire` to create a new connection with an inactive server except that the server should not be in the routing table and therefore should not be used to `acquire` new connections. When error happens on a connection, we will deactivate the server but we will probably not remove all server's connections from connection pool as the failed connection is highly still inUse by the broken session.
0abb9f8
to
97c8ccd
Compare
Do not purge inUse connections when connection error happens or new routing table is available
Instead we deactive the server (a.k.a. closing all idle connections) in connection pool.
When an connection failure happens, the connection server will be removed from the routing table and all idle connections with this server will be closed in the connection pool.
When a new routing table is available, all idle connections towards the servers that are not in the new routing table will be removed. If the server has no inUse connections, then this server will also be totally removed from the connection pool.
Note:
acquire
to create a new connection with an inactive server except that the server should not be in the routing table and therefore should not be used toacquire
new connections.