[CONPY-174] pool_recycle : reconnect automatically staled/closed connections into the pool Created: 2021-10-20 Updated: 2021-10-21 |
|
| Status: | Open |
| Project: | MariaDB Connector/Python |
| Component/s: | Connection Pooling |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major |
| Reporter: | el dge | Assignee: | Georg Richter |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
Hi, In SQLAlchemy, pool_recycle is super. It replaces staled/closed old connection. There is an almost equivalent with ping/reconnect https://mariadb.com/docs/reference/conpy/api/reconnect/, but that would be great that this mechanism (ping/reconnect if necessary) be integrated automatically into ConnectionPool. Otherwise, just a timer in ConnectionPool parameter, and at its expiration reconnect. Thx a lot in advance. |
| Comments |
| Comment by el dge [ 2021-10-20 ] | ||||||
|
Sorry, I think I found a solution with auto_reconnect.
And it's ok, after MariaDB has closed the connections (after wait_timeout expire), cnx.get_connection() still works. PS: It's not very elegant solution, why not insert an auto_reconnect parameter into the constructor of ConnectionPool ? | ||||||
| Comment by el dge [ 2021-10-20 ] | ||||||
|
However, auto_reconnect does not work if MariaDB is restarted... | ||||||
| Comment by el dge [ 2021-10-21 ] | ||||||
|
It's perhaps an error of programming , but when I spawn 10 process (0 thread) with uwsgi of my program. When all connection are closed, and auto_reconnect come, 90 (size of pool * number of process) connections appear instead 9 (size of pool) ! I can provide code example if necessary. |