REQ-3284: 查询数量过大告警
This commit is contained in:
parent
d9b2b18913
commit
f92d5e9c3c
@ -57,7 +57,15 @@ class ProxyStatement extends StatementWrapper {
|
||||
|
||||
void rowAdvanced() {
|
||||
rowCount++;
|
||||
tryWarnFor("Threshold", true);
|
||||
if (rowCountAboveThreshold() && canWarnPeriodically()) {
|
||||
warnFor("Threshold");
|
||||
periodWarnTimes++;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean canWarnPeriodically() {
|
||||
int maxWarnTimes = props.getRowCount().getPeriodMaxWarnTimes();
|
||||
return rowCount % 2000 == 0 && periodWarnTimes <= maxWarnTimes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -76,17 +84,13 @@ class ProxyStatement extends StatementWrapper {
|
||||
@Override
|
||||
public void close() throws SQLException {
|
||||
super.close();
|
||||
if (!closeWarned) {
|
||||
tryWarnFor("StatementClose", false);
|
||||
if (rowCountAboveThreshold() && !closeWarned) {
|
||||
warnFor("StatementClose");
|
||||
closeWarned = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void tryWarnFor(String phase, boolean periodically) {
|
||||
if (!rowCountAboveThreshold()) return;
|
||||
if (periodically && !canWarnPeriodically()) return;
|
||||
if (periodically)
|
||||
periodWarnTimes++;
|
||||
private void warnFor(String phase) {
|
||||
try {
|
||||
// make a copy
|
||||
int rowCount = this.rowCount;
|
||||
@ -109,11 +113,6 @@ class ProxyStatement extends StatementWrapper {
|
||||
return rowCount > props.getRowCount().determineWarningThreshold();
|
||||
}
|
||||
|
||||
private boolean canWarnPeriodically() {
|
||||
int maxWarnTimes = props.getRowCount().getPeriodMaxWarnTimes();
|
||||
return rowCount % 2000 == 0 && periodWarnTimes <= maxWarnTimes;
|
||||
}
|
||||
|
||||
private void sendWarn(String phase, int currentCount, String traceId) {
|
||||
DingTalkService dingTalkService = beanFactory
|
||||
.getBeanProvider(DingTalkService.class).getIfAvailable();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user