netease-youdao / QAnything

Question and Answer based on Anything.
https://qanything.ai
GNU Affero General Public License v3.0
11.98k stars 1.17k forks source link

[BUG] <mysql.connector.errors.PoolError: Failed getting connection; pool exhausted> #95

Open OneStepAndTwoSteps opened 10 months ago

OneStepAndTwoSteps commented 10 months ago

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

当前行为 | Current Behavior

您好,我在创建知识库的时候遇到了无法创建的问题,我在审查log的时候发现了这样的问题:

mysql.connector.errors.PoolError: Failed getting connection; pool exhausted

我查看了我当前docker-mysql的连接数为3,支持的最大连接数为151,我不知道为什么还会出现这样的报错。

以及我在每一次刷新我的页面后,原先创建好的知识库就消失不见。

期望行为 | Expected Behavior

我希望能够正常的创建知识库,以及每一次刷新页面的时候,原先创建好的知识库可以正常显示。

运行环境 | Environment

- OS:Ubuntu 22.04.2
- NVIDIA Driver:525.125.06
- CUDA: CUDA 12.0
- Docker Compose:1.29.2
- NVIDIA GPU Memory:A800 80G

QAnything日志 | QAnything logs

sanic_api.log

Traceback (most recent call last): File "handle_request", line 97, in handle_request File "/workspace/qanything_local/qanything_kernel/qanything_server/handler.py", line 35, in new_knowledge_base local_doc_qa.create_milvus_collection(user_id, kb_id, kb_name) File "/workspace/qanything_local/qanything_kernel/core/local_doc_qa.py", line 59, in create_milvus_collection self.milvus_summary.new_milvus_base(kb_id, user_id, kb_name) File "/workspace/qanything_local/qanything_kernel/connector/database/mysql/mysql_client.py", line 199, in new_milvus_base if not self.check_userexist(user_id): File "/workspace/qanything_local/qanything_kernel/connector/database/mysql/mysql_client.py", line 129, in check_userexist result = self.executequery(query, (user_id,), fetch=True) File "/workspace/qanything_local/qanything_kernel/connector/database/mysql/mysql_client.py", line 57, in executequery conn = self.cnxpool.get_connection() File "/usr/local/lib/python3.10/dist-packages/mysql/connector/pooling.py", line 579, in get_connection raise PoolError("Failed getting connection; pool exhausted") from err mysql.connector.errors.PoolError: Failed getting connection; pool exhausted

debug.log:

2024-02-01 09:48:39,156 - [PID: 1958][Sanic-Server-3-0] - [Function: list_kbs] - INFO - list_kbs zzp 2024-02-01 09:48:42,079 - [PID: 1958][Sanic-Server-3-0] - [Function: new_knowledge_base] - INFO - new_knowledge_base zzp 2024-02-01 09:48:42,095 - [PID: 1958][Sanic-Server-3-0] - [Function: init] - INFO - collection zzp exists 2024-02-01 09:48:42,113 - [PID: 1958][Sanic-Server-3-0] - [Function: init] - INFO - partitions: ['KB358e2575045645f8bfe7fc89df0df0f9']

复现方法 | Steps To Reproduce

No response

备注 | Anything else?

No response

xixihahaliu commented 7 months ago

尝试手动改大连接池size:qanything_kernel/connector/database/mysql/mysql_client.py 将pool_size从5改成32,你这个问题可能是并发量较大耗尽mysql连接导致的,关于“以及我在每一次刷新我的页面后,原先创建好的知识库就消失不见。”,则是因为前端显示的知识库实际是去mysql中查询获取的,mysql连接失败前端就无法获取知识库的信息