-
Notifications
You must be signed in to change notification settings - Fork 46
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
Introduce ConnectionPool with master discovery #207
Introduce ConnectionPool with master discovery #207
Conversation
67f85d1
to
c960ade
Compare
Never look at box.cfg.read_only. Look only at box.info.ro |
It was used only in tests, reworked |
Alternative approachesSynchronous on request (on errors)Solution idea: refresh schema (rw/ro info, replication state) on connect, RO error or network error. Pros
Cons
Synchronous on request (with timeout)Solution idea: refresh schema (rw/ro info, replication state) before request if X milliseconds have passed since last refresh. Pros
Cons
AsynchronousSolution idea: refresh schema (rw/ro info, replication state) in separate thread each X milliseconds. Pros
Cons
What solution should we choose?Solutions may be hybrid (1+2 or 1+3), and I think it would be the best approach to cover more cases. Personally I prefer synchronous on request on error + timeout: the only drawback is increasing latency for some requests, but it's rather simple to implement compared to introducing async. It is much harder to combine synchronous refresh on error and async approach, and using pure async approach will pass responsibility to implement non-trivial retry logic to app developers. |
60df77b
to
ff68de5
Compare
59d1095
to
d16c16d
Compare
6aa89a6
to
29c4ba2
Compare
d16c16d
to
32190f3
Compare
760e1cf
to
8772bc7
Compare
8772bc7
to
155b1d7
Compare
0bd9fb5
to
6c2bac7
Compare
An RO instance can write to a replica local or a temporary space. Well, it is strange to write to a replica local space on some RO instance. However there may be a use case: say, register a task to be proceeded in background. I think we should have good defaults, but allow to choose anyway. |
4ec6748
to
88fa990
Compare
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.
LGTM aside of several minor comments.
Please, finish review with Anastasia and proceed.
39f5a6b
to
aa0b5b9
Compare
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.
LGTM.
150751a
to
f4087ad
Compare
Python 2.7 reached the end of its life on January 1st, 2020 [1]. Since it would be a waste to ignore several Python 3.x features in master discovery implementation, we decided to drop Python 2 support here. Python 2 workaround cleanup activities are expected to be solved as part of #212 solution. 1. https://www.python.org/doc/sunset-python-2/ Part of #196
Introduce connection interface to be used in connection pool implementation. Only CRUD and base connect/close API is required by the interface. Part of #196
Introduce ConnectionPool class to work with cluster of Tarantool instances. ConnectionPool support master discovery and ro/rw-based requests, so it is most useful while working with a single replicaset of instances. ConnectionPool is supported only for Python 3.7 or newer. Authenticated user must be able to call `box.info` on instances. ConnectionPool updates information about each server state (RO/RW) on initial connect and then asynchronously in separate threads. Application retries must be written considering the asynchronous nature of cluster state refresh. User does not need to use any synchronization mechanisms in requests, it's all handled with ConnectionPool methods. ConnectionPool API is the same as a plain Connection API. On each request, a connection is chosen to execute this request. A connection is chosen based on a request mode: * Mode.ANY chooses any instance. * Mode.RW chooses an RW instance. * Mode.RO chooses an RO instance. * Mode.PREFER_RW chooses an RW instance, if possible, RO instance otherwise. * Mode.PREFER_RO chooses an RO instance, if possible, RW instance otherwise. All requests that are guaranteed to write (insert, replace, delete, upsert, update) use RW mode by default. select uses ANY by default. You can set the mode explicitly. call, eval, execute and ping requests require to set the mode explicitly. Example: pool = tarantool.ConnectionPool( addrs=[ {'host': '108.177.16.0', 'port': 3301}, {'host': '108.177.16.0', 'port': 3302}, ], user='test', password='test',) pool.call('some_write_procedure', arg, mode=tarantool.Mode.RW) Closes #196
f4087ad
to
2546490
Compare
Since the release of tarantool/python 0.8.0 [1] several things has changed. * Issue #105 has been fixed [2]. * CI has been migrated to GitHub Actions [3]. * New connection pool (ConnectionPool) with master discovery was introduced [4]. * old connection pool (MeshConnection) with round-robin failover was deprecated [4]. These changes together with GitHub stars update are introduced with this patch. 1. https://github.com/tarantool/tarantool-python/releases/tag/0.8.0 2. tarantool/tarantool-python#211 3. tarantool/tarantool-python#213 4. tarantool/tarantool-python#207
Since the release of tarantool-python 0.8.0 [1] several things has changed. * Issue tarantool/tarantool-python#105 has been fixed [2]. * CI has been migrated to GitHub Actions [3]. * New connection pool (ConnectionPool) with master discovery was introduced [4]. * old connection pool (MeshConnection) with round-robin failover was deprecated [4]. These changes together with GitHub stars update are introduced with this patch. 1. https://github.com/tarantool/tarantool-python/releases/tag/0.8.0 2. tarantool/tarantool-python#211 3. tarantool/tarantool-python#213 4. tarantool/tarantool-python#207
Since the release of tarantool-python 0.8.0 [1] several things has changed. * Issue tarantool/tarantool-python#105 has been fixed [2]. * CI has been migrated to GitHub Actions [3]. * New connection pool (ConnectionPool) with master discovery was introduced [4]. * old connection pool (MeshConnection) with round-robin failover was deprecated [4]. These changes together with GitHub stars update are introduced with this patch. 1. https://github.com/tarantool/tarantool-python/releases/tag/0.8.0 2. tarantool/tarantool-python#211 3. tarantool/tarantool-python#213 4. tarantool/tarantool-python#207
Since the release of tarantool-python 0.8.0 [1] several things has changed. * Issue tarantool/tarantool-python#105 has been fixed [2]. * CI has been migrated to GitHub Actions [3]. * New connection pool (ConnectionPool) with master discovery was introduced [4]. * old connection pool (MeshConnection) with round-robin failover was deprecated [4]. These changes together with GitHub stars update are introduced with this patch. 1. https://github.com/tarantool/tarantool-python/releases/tag/0.8.0 2. tarantool/tarantool-python#211 3. tarantool/tarantool-python#213 4. tarantool/tarantool-python#207
* Update python connector comparison table Since the release of tarantool-python 0.8.0 [1] several things has changed. * Issue tarantool/tarantool-python#105 has been fixed [2]. * CI has been migrated to GitHub Actions [3]. * New connection pool (ConnectionPool) with master discovery was introduced [4]. * old connection pool (MeshConnection) with round-robin failover was deprecated [4]. These changes together with GitHub stars update are introduced with this patch. 1. https://github.com/tarantool/tarantool-python/releases/tag/0.8.0 2. tarantool/tarantool-python#211 3. tarantool/tarantool-python#213 4. tarantool/tarantool-python#207 * Update translation Co-authored-by: Patience Daur <[email protected]>
python: drop Python 2 support
Python 2.7 reached the end of its life on January 1st, 2020 [1]. Since
it would be a waste to ignore several Python 3.x features in master
discovery implementation, we decided to drop Python 2 support here.
Python 2 workaround cleanup activities are expected to be solved as
part of #212 solution.
connection: introduce common interface
Introduce connection interface to be used in connection pool
implementation. Only CRUD and base connect/close API is required
by the interface.
Part of #196
connection_pool: introduce connection pool
Introduce ConnectionPool class to work with cluster of Tarantool
instances. ConnectionPool support master discovery and ro/rw-based
requests, so it is most useful while working with a single replicaset of
instances. ConnectionPool is supported only for Python 3.7 or newer.
Authenticated user must be able to call
box.info
on instances.ConnectionPool updates information about each server state (RO/RW)
on initial connect and then asynchronously in separate threads.
Application retries must be written considering the asynchronous nature
of cluster state refresh. User does not need to use any synchronization
mechanisms in requests, it's all handled with ConnectionPool methods.
ConnectionPool API is the same as a plain Connection API.
On each request, a connection is chosen to execute this request.
Connection is selected based on request mode:
otherwise.
otherwise.
All requests that are guaranteed to write (insert, replace, delete,
upsert, update) use RW mode by default. select uses ANY by default. You
can set the mode explicitly. call, eval, execute and ping requests
require to set the mode explicitly.
Example:
Closes #196