mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
IN PROGRESS - issue DRUID-82: 当sql没有参数化时,sql数量过多会导致OOM
http://code.alibabatech.com/jira/browse/DRUID-82
This commit is contained in:
@@ -67,6 +67,8 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
protected final AtomicLong resetCount = new AtomicLong();
|
||||
|
||||
protected int maxSqlStatCount = 1000 * 10;
|
||||
|
||||
public boolean isConnectionStackTraceEnable() {
|
||||
return connectionStackTraceEnable;
|
||||
}
|
||||
@@ -81,10 +83,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
|
||||
public void reset() {
|
||||
dataSourceStat.reset();
|
||||
|
||||
|
||||
resetCount.incrementAndGet();
|
||||
}
|
||||
|
||||
|
||||
public long getResetCount() {
|
||||
return resetCount.get();
|
||||
}
|
||||
@@ -670,6 +672,10 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
|
||||
final ConcurrentMap<String, JdbcSqlStat> sqlStatMap = dataSourceStat.getSqlStatMap();
|
||||
JdbcSqlStat sqlStat = sqlStatMap.get(sql);
|
||||
if (sqlStat == null) {
|
||||
if (dataSourceStat.getSqlStatMap().size() >= maxSqlStatCount) {
|
||||
return null;
|
||||
}
|
||||
|
||||
JdbcSqlStat newSqlStat = new JdbcSqlStat(sql);
|
||||
if (dataSourceStat.getSqlStatMap().putIfAbsent(sql, newSqlStat) == null) {
|
||||
newSqlStat.setId(JdbcStatManager.getInstance().generateSqlId());
|
||||
|
||||
Reference in New Issue
Block a user