MySQL connections are not closed in hadoop sqk #2825
Replies: 8 comments
-
每个进程会有多少个连接? |
Beta Was this translation helpful? Give feedback.
-
有多个进程使用hadoop sdk连接juicefs,单个进程最多有测试过40个连接 |
Beta Was this translation helpful? Give feedback.
-
连接数取决于业务访问的并发量,并发高则需要更多连接,因为MySQL 没法多个事务公用连接。可以观察一下当业务停止访问后,连接是否会释放,闲置多长时间后会释放,可以尝试调整一下空闲连接释放相关的参数。 |
Beta Was this translation helpful? Give feedback.
-
已经观察过了,业务已经停止运行,在juicefs.access-log对应的日志里面也已经没有输出对应的文件访问日志,但是mysql一直有收到如下sql语句: |
Beta Was this translation helpful? Give feedback.
-
这些是定时任务,应该只会需要一两个连接。在停止业务后,还会一直有 40 个连接? |
Beta Was this translation helpful? Give feedback.
-
是的,停止业务后还一直会有40个连接。通过mysql的show processlist和general_log跟踪,发现这些mysql连接一直会被前面贴出来的那些请求激活从而导致不会空闲太久。猜测这些定时任务应该是每次触发时都随机从连接池里面拿去一个连接来访问。 |
Beta Was this translation helpful? Give feedback.
-
JuiceFS set the max idle time to 5 minutes, and sql driver will try to use few connections as possible, so it should not have more than 4 connections after 5 minutes. We will try to reproduce this. |
Beta Was this translation helpful? Give feedback.
-
We didn't reproduce this problem. If you can reproduce this problem, please provide a stable way to reproduce. |
Beta Was this translation helpful? Give feedback.
-
hadoop sqk模式会频繁读取mysql元数据信息导致mysql连接池的连接一直是处于激活状态而不会被回收,建议降低内置读取元数据信息的频率或者使用同一个连接来读取。
高频执行的sql语句如下:
SELECT name,value from 'jfs_setting' Where name = 'format' LIMIT 1;
SELECT name,value from 'jfs_counter' Where name = 'usedSpace' LIMIT 1;
SELECT name,value from 'jfs_counter' Where name = 'totalInodes' LIMIT 1;
SELECT name,value from 'jfs_counter' Where name = 'lastCleanupSessions' LIMIT 1;
Beta Was this translation helpful? Give feedback.
All reactions