Do not purge inUse connections - #197
Merged
Merged
Conversation
zhenlineo
force-pushed
the
1.5-purge-idle
branch
4 times, most recently
from
November 24, 2017 12:52
b1cd45c to
0abb9f8
Compare
technige
reviewed
Nov 29, 2017
| self.ttl = new_routing_table.ttl | ||
|
|
||
| def servers(self): | ||
| return set(self.routers.elements() + self.writers.elements() + self.readers.elements()) |
Contributor
There was a problem hiding this comment.
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.
technige
reviewed
Nov 29, 2017
| e.update(OrderedDict.fromkeys(elements)) | ||
|
|
||
| def elements(self): | ||
| return list(self._elements) |
technige
reviewed
Nov 29, 2017
| conn.close() | ||
| except IOError: | ||
| pass | ||
| if len(connections) == 0: |
added 2 commits
November 29, 2017 13:44
…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.
zhenlineo
force-pushed
the
1.5-purge-idle
branch
from
November 29, 2017 12:47
0abb9f8 to
97c8ccd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
acquireto 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 toacquirenew connections.