[CONPY-216] Process hang while invoke ConnectionPool.get_connection() Created: 2022-07-18  Updated: 2022-07-19

Status: Open
Project: MariaDB Connector/Python
Component/s: Connection Pooling
Affects Version/s: 1.0.11
Fix Version/s: None

Type: Bug Priority: Major
Reporter: long jin Assignee: Georg Richter
Resolution: Unresolved Votes: 0
Labels: None
Environment:

debian 10


Attachments: PNG File image-2022-07-18-17-33-57-580.png    
Python Version: 3.8

 Description   

Hi, may be I found a bug in ConnectionPool.get_connection().

You can reproduce the problem through the following steps:

  1. Assume the mariadb server is running on host A, and you do follow steps with host B
  2. Create a connection pool
    ```
    _pool = mariadb.ConnectionPool(
    host=constant.DB_HOST,
    port=constant.DB_PORT,
    user=constant.DB_USER,
    password=constant.DB_PASSWORD,
    pool_name=constant.DB_POOL_NAME,
    db=constant.DB_NAME,
    pool_size=constant.DB_POOL_SIZE,
    autocommit=True)
    ```
  3. Disconnect host B's network.(By shutdown the NIC)
  4. Reconnect host B's network
  5. invoke `ConnectionPool.get_connection()`

Then the program will fall into a dead cycle which "ping-failed-continue-ping". I think, this is a bug



 Comments   
Comment by Georg Richter [ 2022-07-18 ]

Hi,

get_connection method loops over connections which aren't in use, tries to ping and returns. If all connections became invalid, it needs to loop over all connections. Why do you think it is a bug?

Comment by long jin [ 2022-07-18 ]

Hmm, but in the case above, if all connections are invalid, the function may not return, even a `None`.

Comment by long jin [ 2022-07-19 ]

May be we can try to reconnect the connection in the get_connection() function when the conn is broken.

Generated at Thu Feb 08 03:31:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.