You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Kathey Marsden (JIRA)" <ji...@apache.org> on 2013/06/14 00:39:20 UTC
[jira] [Assigned] (DERBY-6055) Drained metadata result sets can
cause build up of open statements open on client/server until gc kicks in
[ https://issues.apache.org/jira/browse/DERBY-6055?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kathey Marsden reassigned DERBY-6055:
-------------------------------------
Assignee: (was: Kathey Marsden)
Not currently working on this issue
> Drained metadata result sets can cause build up of open statements open on client/server until gc kicks in
> ------------------------------------------------------------------------------------------------------------
>
> Key: DERBY-6055
> URL: https://issues.apache.org/jira/browse/DERBY-6055
> Project: Derby
> Issue Type: Bug
> Components: Network Client
> Affects Versions: 10.8.3.0
> Reporter: Kathey Marsden
> Priority: Minor
> Labels: derby_triage10_11
>
> With client/server, depending on when garbage collection kicks in metadata related statements can build up until garbage collection. This is only potentially an issue I think with client where there is a limit of 32K statements and only if there is some sort of extremely deferred garbage collection.
> The program below shows the issue which is easy enough to work around by closing the statement associated with the metadata result set, uncommenting the line.
> //rs.getStatement().close();
> import java.sql.*;
> import java.net.*;
> import java.io.*;
> import org.apache.derby.drda.NetworkServerControl;
> /**
> * Show client/server Metadata statements can build up even when
> * Metadata result sets have been closed.
> */
> public class MetaDataStatements {
>
> public static void main(String[] args) throws Exception {
> try {
> // Load the driver. Not needed for network server.
>
> Class.forName("org.apache.derby.jdbc.ClientDriver");
> // Start Network Server
> startNetworkServer();
> // If connecting to a customer database. Change the URL
> Connection conn = DriverManager
> .getConnection("jdbc:derby://localhost:1527/wombat;create=true");
> // clean up from a previous run
> Statement s = conn.createStatement();
> try {
> s.executeUpdate("DROP TABLE T");
> } catch (SQLException se) {
> if (!se.getSQLState().equals("42Y55"))
> throw se;
> }
>
> for (int i = 0; i < 50000; i++) {
> ResultSet rs = conn.getMetaData().getSchemas();
> while (rs.next()) {
> //System.out.println("SCHEM NAME = " + rs.getString(1));
> }
> //rs.getStatement().close();
> }
>
> // rs.close();
> // ps.close();
> // s.close();
> runtimeInfo();
> conn.close();
> // Shutdown the server
> shutdownServer();
> } catch (SQLException se) {
> while (se != null) {
> System.out.println("SQLState=" + se.getSQLState()
> + se.getMessage());
> se.printStackTrace();
> se = se.getNextException();
> }
> }
> }
>
> /**
> * starts the Network server
> *
> */
> public static void startNetworkServer() throws SQLException {
> Exception failException = null;
> try {
>
> NetworkServerControl networkServer = new NetworkServerControl(
> InetAddress.getByName("localhost"), 1527);
>
> networkServer.start(new PrintWriter(System.out));
>
> // Wait for the network server to start
> boolean started = false;
> int retries = 10; // Max retries = max seconds to wait
>
> while (!started && retries > 0) {
> try {
> // Sleep 1 second and then ping the network server
> Thread.sleep(1000);
> networkServer.ping();
>
> // If ping does not throw an exception the server has
> // started
> started = true;
> } catch (Exception e) {
> retries--;
> failException = e;
> }
>
> }
>
> // Check if we got a reply on ping
> if (!started) {
> throw failException;
> }
> } catch (Exception e) {
> SQLException se = new SQLException("Error starting network server");
> se.initCause(failException);
> throw se;
> }
> }
>
> public static void shutdownServer() throws Exception {
> NetworkServerControl networkServer = new NetworkServerControl(
> InetAddress.getByName("localhost"), 1527);
> networkServer.shutdown();
> }
>
> public static void runtimeInfo() throws Exception {
> NetworkServerControl networkServer = new NetworkServerControl(
> InetAddress.getByName("localhost"), 1527);
> System.out.println(networkServer.getRuntimeInfo());
> }
>
> }
> ---------- Session Information ---------------
> Session # :2
> Database :wombat;create=true
> User :APP
> # Statements:59
> Prepared Statement Information:
> Stmt ID SQLText
> ------------- -----------
> SYSLH00032 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00033 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00060 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00058 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00059 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00056 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00057 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00054 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
> SYSLH00055 CALL SYSIBM.SQLTABLES('', '', '', '', 'GETSCHEMAS=1')
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira