Bug 728272

Summary: make sure JDBC connections, statements, and resultsets get closed after we are done with them
Product: [Other] RHQ Project Reporter: Ian Springer <ian.springer>
Component: Core ServerAssignee: RHQ Project Maintainer <rhq-maint>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: low    
Version: 4.0.1CC: ccrouch, hrupp, rbuck
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-07 19:27:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 678340, 717358    

Description Ian Springer 2011-08-04 14:43:50 UTC
Coverity reports dozens of places in the RHQ Server code where we don't close connections, statements, and resultsets. Sometimes we don't close them when an exception occurs, and other times we don't close them even in the non-exception case.

In our perf environment, Oracle EM is warning that it has 5000 open cursors. There are probably so many because of the un-closed/abandoned connections, statements, and resultsets.

JBoss AS can be configured to auto-close abandoned connections, statements, and resultsets.

http://community.jboss.org/wiki/WhatDoesTheMessageDoYourOwnHousekeepingMean
http://community.jboss.org/wiki/CanJBossTellMeWhenIDontCloseAConnection

The RHQ Server AS is already configured to auto-close connections, but not to auto-close statements and resultsets. To do the latter, we need to add:

  <track-statements>true</track-statements>

to both of the datasources defined in rhq-ds.xml.

Whenever JBoss auto-closes a connection, statement, and resultset, it logs a nasty warning, so, longer term, we should go through our code and make sure to close the connections, statements, and resultsets ourselves. Coverity will give us a list of all of the culprits.

Comment 1 Ian Springer 2011-08-04 14:53:12 UTC
I added <track-statements>true</track-statements> to each of the RHQ datasources in the perftest branch - commit cbef4d2. Once this has been tested in the perf env, we'll merge it into master.

Comment 2 Robert Buck 2011-09-26 12:56:00 UTC
commit fece00f1862612104aef1439fb02c4f7a35d797e
Author: Robert Buck <rbuck>
Date:   2011-09-26 08:54:05 -0400

oracle em cites lots of open cursor issues; fix open cursor leaks by closing result sets and prepared statements in finally blocks.

Comment 3 Mike Foley 2011-09-29 19:44:03 UTC
verified general functionality through successful automation run.

Comment 4 Mike Foley 2012-02-07 19:27:22 UTC
changing status of VERIFIED BZs for JON 2.4.2 and JON 3.0 to CLOSED/CURRENTRELEASE