[Bug] 1.5.0 mysql backend内存泄漏
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- java, mysql
- Domain
- database, performance
Research direction
Search the Java codebase for ResultSetWrapper and inspect how its resultSet and statement are created, used, and closed. Reproduce the MySQL backend workload on version 1.5.0 while checking logs or a memory dump, then verify that resources are released consistently and memory no longer grows until exhaustion.
Written by the indexing model from the issue text.
Description
Bug Type (问题类型)
performance (性能下降)
Before submit
- 我已经确认现有的 Issues 与 FAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
Environment (环境信息)
- Server Version: 1.5.0 (Apache Release Version)
- Backend: Mysql
- OS: CentOS 7.x
Expected & Actual behavior (期望与实际表现)
- 问题描述:
1、内存dump中mysql驱动实例呈线性增长趋势
2、gc回收后占用空间没有下降,直至内存溢出 - 问题分析
在ResultSetWrapper中创建和close方法中分别加入日志,发现存在一定比例的ResultSetWrapper没有正常调用关闭方法。 - 问题解决
在ResultSetWrapper中加入finalize方法,在回收前判断resultSet和statement有没有正常关闭,未关闭则处理
加入此处理后问题解决。
@Override
protected void finalize() {
try {
if (this.resultSet != null && !this.resultSet.isClosed()) {
LOG.warn("resultSet was not closed properly, forcing close via finalize");
this.resultSet.close();
}
} catch (SQLException e) {
throw new BackendException("Failed to close ResultSet", e);
} finally {
try {
if (this.statement != null && !this.statement.isClosed()) {
LOG.warn("statement was not closed properly, forcing close via finalize");
this.statement.close();
}
} catch (SQLException e) {
throw new BackendException("Failed to close Statement", e);
}
}
}
Vertex/Edge example (问题点 / 边数据举例)
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 637
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 23
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/hugegraph
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
All issues in apache/hugegraph
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100