Bug #41857 Simillar bug as 25514
Submitted: 5 Jan 2009 9:29 Modified: 13 Apr 2015 7:37
Reporter: Bhaskar Roy Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / J Severity:S1 (Critical)
Version:5.0.7 OS:Linux ( 2.4.20-8 #1 Thu Mar 13 17:54:28 EST 2003 i686 i686 i386 GNU/Linux)
Assigned to: Alexander Soklakov CPU Architecture:Any
Tags: 25514

[5 Jan 2009 9:29] Bhaskar Roy
Description:
Getting the similar issue as #25514, for J/Connect 5.1.7, here is the code dump -

-bash-2.05b# java TimerThreadIssue username password
Executing iteration 0
Executing iteration 1
Executing iteration 2
Executing iteration 3
Executing iteration 4
Executing iteration 5
Executing iteration 6
Executing iteration 7
Executing iteration 8
Executing iteration 9
ctrl-backslash to thread dump now...
Full thread dump Java HotSpot(TM) Client VM (1.5.0_17-b04 mixed mode, sharing):

"MySQL Statement Cancellation Timer" daemon prio=1 tid=0x0820c490 nid=0x5a39 in Object.wait() [0x41d89000..0x41d89f9c]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x66cbf048> (a java.util.TaskQueue)
        at java.lang.Object.wait(Object.java:474)
        at java.util.TimerThread.mainLoop(Timer.java:483)
        - locked <0x66cbf048> (a java.util.TaskQueue)
        at java.util.TimerThread.run(Timer.java:462)

"Low Memory Detector" daemon prio=1 tid=0x080a5988 nid=0x5a37 runnable [0x00000000..0x00000000]

"CompilerThread0" daemon prio=1 tid=0x080a4478 nid=0x5a36 waiting on condition [0x00000000..0x4175ab84]

"Signal Dispatcher" daemon prio=1 tid=0x080a3638 nid=0x5a35 waiting on condition [0x00000000..0x00000000]

"Finalizer" daemon prio=1 tid=0x0809c8e8 nid=0x5a34 in Object.wait() [0x4145b000..0x4145b39c]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x66c62e78> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:120)
        - locked <0x66c62e78> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:136)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=1 tid=0x0809bca8 nid=0x5a33 in Object.wait() [0x413db000..0x413db59c]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x66c62f00> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:474)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x66c62f00> (a java.lang.ref.Reference$Lock)

"main" prio=1 tid=0x0805ca10 nid=0x5a31 waiting on condition [0xbfffb000..0xbfffbfb8]
        at java.lang.Thread.sleep(Native Method)
        at TimerThreadIssue.main(TimerThreadIssue.java:35)

"VM Thread" prio=1 tid=0x0809a878 nid=0x5a32 runnable

"VM Periodic Task Thread" prio=1 tid=0x080a6dd8 nid=0x5a38 waiting on condition

...Exiting

Because of this issue, whenever we are starting our Apache Portal server, the J/Connector hangs and we can't work on our application.

I need to know, if that fix suggested in #25514 has to be applied for this upgraded version or those fixes are already there.

How to repeat:
Here is the code executed -

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class TimerThreadIssue {

    public static void main(String[] args) throws Exception {

        String username = args[0];
        String password = args[1];

        Class.forName("com.mysql.jdbc.Driver");
        String hostname = "localhost";
        String port = "3306";
        String schema = "mysql";
        String url = "jdbc:mysql://"+hostname+":"+port+"/"+schema+"?jdbcCompliantTruncation=false&explainSlowQueries=true&dumpQueriesOnException=true&zeroDateTimeBehavior=convertToNull&enablePacketDebug=true";

        for(int i=0; i<10; i++) {
            System.out.println("Executing iteration "+i);

            Connection conn = DriverManager.getConnection(url, username, password);
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery( "select count(*) from user" );
            rs.next();
            rs.getInt(1);
            rs.close();
            stmt.close();
            conn.close();

            Thread.sleep(1000);
        }

        System.out.println("ctrl-backslash to thread dump now...");
        Thread.sleep(5000);
        System.out.println("...Exiting");

    }

}
[5 Jan 2009 16:54] Bhaskar Roy
is it fixed in 5.0.8?
[5 Jan 2009 17:19] Bhaskar Roy
tested with Connecter/J 5.0.8, same issue.
[6 Jan 2009 18:37] Mark Matthews
I don't see a "hang" in this thread dump, your application is sleeping where you ask it to sleep. What does the one from your real application look like?
[7 Jan 2009 4:21] Bhaskar Roy
Here is the thread dump of Apache portal, hope that helps to understand our problem (complete file attached) -

##### platform = MySQL
2009-01-05 10:29:23
Full thread dump Java HotSpot(TM) Server VM (1.6.0_02-b05 mixed mode):

"Thread-2" daemon prio=10 tid=0x088e9800 nid=0x5cce waiting on condition [0x40d5b000..0x40d5c09c]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
	at java.lang.Thread.sleep(Native Method)
	at org.apache.jetspeed.cache.file.FileCache$FileCacheScanner.run(FileCache.java:439)

"MySQL Statement Cancellation Timer" daemon prio=10 tid=0x08cfe000 nid=0x5ccb in Object.wait() [0x40d0c000..0x40d0c19c]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x4714b038> (a java.util.TaskQueue)
	at java.lang.Object.wait(Object.java:485)
	at java.util.TimerThread.mainLoop(Timer.java:483)
	- locked <0x4714b038> (a java.util.TaskQueue)
	at java.util.TimerThread.run(Timer.java:462)

"Low Memory Detector" daemon prio=10 tid=0x08106000 nid=0x5cc8 runnable [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread1" daemon prio=10 tid=0x08104800 nid=0x5cc7 waiting on condition [0x00000000..0x4094d6f4]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x08103000 nid=0x5cc6 waiting on condition [0x00000000..0x408cd7f4]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x08101c00 nid=0x5cc5 waiting on condition [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=10 tid=0x080eec00 nid=0x5cc4 in Object.wait() [0x405fe000..0x405fe39c]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x46ddec20> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
	- locked <0x46ddec20> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x080ee400 nid=0x5cc3 in Object.wait() [0x405ae000..0x405ae49c]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x46ddecb0> (a java.lang.ref.Reference$Lock)
	at java.lang.Object.wait(Object.java:485)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
	- locked <0x46ddecb0> (a java.lang.ref.Reference$Lock)

"main" prio=10 tid=0x08057c00 nid=0x5cc1 runnable [0x400ac000..0x400af6f4]
   java.lang.Thread.State: RUNNABLE
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
	- locked <0x45152db0> (a java.net.SocksSocketImpl)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:518)
	at java.net.Socket.connect(Socket.java:468)
	at java.net.Socket.<init>(Socket.java:365)
	at java.net.Socket.<init>(Socket.java:179)
	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
	at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
	at sun.rmi.registry.RegistryImpl_Stub.list(Unknown Source)
	at net.sf.ehcache.distribution.RMICacheManagerPeerListener.startRegistry(RMICacheManagerPeerListener.java:308)
	at net.sf.ehcache.distribution.RMICacheManagerPeerListener.init(RMICacheManagerPeerListener.java:193)
	at net.sf.ehcache.CacheManager.init(CacheManager.java:213)
	at net.sf.ehcache.CacheManager.<init>(CacheManager.java:195)
	at org.springframework.cache.ehcache.EhCacheManagerFactoryBean.afterPropertiesSet(EhCacheManagerFactoryBean.java:106)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)
	at ....
	- locked <0x47021a08> (a org.apache.catalina.core.StandardWrapper)
	at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:932)
	- locked <0x47021a08> (a org.apache.catalina.core.StandardWrapper)
	at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3951)
	at org.apache.catalina.core.StandardContext.start(StandardContext.java:4225)
	- locked <0x46f7c8e8> (a org.apache.catalina.core.StandardContext)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
	- locked <0x46f17a48> (a java.util.HashMap)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
	at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
	at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
	at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
	at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
	at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
	- locked <0x46f13b70> (a org.apache.catalina.core.StandardHost)
	at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
	- locked <0x46f13b70> (a org.apache.catalina.core.StandardHost)
	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
	- locked <0x46ef76f0> (a org.apache.catalina.core.StandardEngine)
	at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
	at org.apache.catalina.core.StandardService.start(StandardService.java:450)
	- locked <0x46ef76f0> (a org.apache.catalina.core.StandardEngine)
	at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
	- locked <0x46f21150> (a [Lorg.apache.catalina.Service;)
	at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)

"VM Thread" prio=10 tid=0x080eb800 nid=0x5cc2 runnable 

"VM Periodic Task Thread" prio=10 tid=0x08107800 nid=0x5cc9 waiting on condition 

JNI global references: 786

Heap
 def new generation   total 960K, used 111K [0x45140000, 0x45240000, 0x46db0000)
  eden space 896K,  10% used [0x45140000, 0x45156ab0, 0x45220000)
  from space 64K,  32% used [0x45220000, 0x452252e0, 0x45230000)
  to   space 64K,   0% used [0x45230000, 0x45230000, 0x45240000)
 tenured generation   total 7552K, used 7295K [0x46db0000, 0x47510000, 0x55140000)
   the space 7552K,  96% used [0x46db0000, 0x474cfff0, 0x474d0000, 0x47510000)
 compacting perm gen  total 16384K, used 15481K [0x55140000, 0x56140000, 0x59140000)
   the space 16384K,  94% used [0x55140000, 0x5605e698, 0x5605e800, 0x56140000)
No shared spaces configured.
[7 Jan 2009 4:22] Bhaskar Roy
Apache Portal log file, hangs with MySql J/Connector

Attachment: catalina.out (application/octet-stream, text), 20.91 KiB.

[12 Feb 2009 13:43] Tonci Grgin
Hi and thanks for your report.

I do not know where to start on this... Did you tried using System.GC?
Also, there is still no proper test case attached to this report.
[13 Mar 2009 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[13 Apr 2015 7:37] Alexander Soklakov
Posted by developer:
 
There is no feedback for 6 years and reported version is too old, so I close it as Can't repeat.