Bug 61391 - SlowQueryReport not logging Failed Query if connection abandoned
Summary: SlowQueryReport not logging Failed Query if connection abandoned
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.x-trunk
Hardware: PC All
: P2 regression (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-08-08 13:50 UTC by Craig Webb
Modified: 2017-08-30 21:15 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Craig Webb 2017-08-08 13:50:49 UTC
In SlowQueryReport.reportFailedQuery() a change has been made to check if QueryStats is null before calling QueryStats.failure(). However, the logging is also included in this if block.

The logging should happen regardless of whether QueryStats is null or not, so that the SQL is logged.

Current code:
QueryStats qs = this.getQueryStats(sql);
if (qs != null) {
   qs.failure(delta, now);
   if (isLogFailed() && log.isWarnEnabled()) {
      log.warn("Failed Query Report SQL="+sql+"; time="+delta+" ms;");
   }
}

Suggested fix:
QueryStats qs = this.getQueryStats(sql);
if (qs != null) {
   qs.failure(delta, now);
}
if (isLogFailed() && log.isWarnEnabled()) {
   log.warn("Failed Query Report SQL="+sql+"; time="+delta+" ms;");
}
Comment 1 Mark Thomas 2017-08-30 21:15:54 UTC
Thanks for the report and the suggested fix.

Fixed in:
- trunk for 9.0.0.M27 onwards
- 8.5.x for 8.5.21 onwards
- 8.0.x for 8.0.47 onwards
- 7.0.x for 7.0.82 onwards