Issue Details (XML | Word | Printable)

Key: JDBC-125
Type: Bug Bug
Status: Resolved Resolved
Resolution: Won't Fix
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Philip Williams
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Jaybird JDBC Driver

EventManager thread spikes CPU when FB shuts down

Created: 04/Aug/08 06:54 PM   Updated: 12/Feb/12 01:08 PM
Component/s: Events
Affects Version/s: Jaybird 2.1.6
Fix Version/s: None

File Attachments: 1. Java Source File JDBC125Reproduction.java (1 kB)

Environment: Tomcat 6, JVM 1.6
Issue Links:
Duplicate
 

Sub-Tasks  All   Open   

 Description  « Hide
If I shutdown Firebird 2.1 while I have a connection in Tomcat set to wait for events asynchronously, CPU usage for Tomcat jumps to 100% immediately and stays that way; cannot call eventManager.disconnect() (it fails while trying to unregister events, does not mark itself as disconnected, cannot be re-used for a new connection). I can detect that the connection has dropped by attempting to register more events (from one of my threads) and this will fail right away -- but then I can't do anything about it. Even if I succeed at reconnecting to FB, the next time the server is shut down I'll have two threads both spinning out of control.

Relevant thread dump follows.

"Thread-4" daemon prio=6 tid=0x27200000 nid=0x23cc runnable [0x2751f000..0x2751fb94]
   java.lang.Thread.State: RUNNABLE
        at org.firebirdsql.gds.impl.wire.XdrInputStream.read(XdrInputStream.java:253)
        at org.firebirdsql.gds.impl.wire.XdrInputStream.readInt(XdrInputStream.java:187)
        at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.nextOperation(AbstractJavaGDSImpl.java:2144)
        at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl$EventCoordinatorImp.run(AbstractJavaGDSImpl.java:3116)
        at java.lang.Thread.run(Unknown Source)

"Thread-3" daemon prio=6 tid=0x2724f400 nid=0x244c in Object.wait() [0x274df000..0x274dfc14]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x05041e60> (a java.util.ArrayList)
        at java.lang.Object.wait(Object.java:485)
        at org.firebirdsql.event.FBEventManager$EventDispatcher.run(FBEventManager.java:445)
        - locked <0x05041e60> (a java.util.ArrayList)
        at java.lang.Thread.run(Unknown Source)

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 20/Feb/10 05:46 PM
Simple program to reproduce behavior ( file needs to be put in package jdbc125)

To reproduce behavior:
setup: enter correct database information in source file, then compile
1) run jdbc125.JDBC125Reproduction
2) Stop the firebirdserver
=> java process spikes to 100% CPU usage

Problem seems to be in XdrInputstream, the underlying SocketInputstream blocks on read, and this blocks indefinitely since no timeout is set in org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl#openSocket(isc_db_handle_impl, DbAttachInfo,
boolean, int)

(my attempt to set a timeout there did not solve this though)

Roman Rokytskyy added a comment - 14/Jul/11 08:40 PM
Strange, I just tried the code and it simply fails with error message in stderr:

Exception in thread "Thread-1" java.lang.RuntimeException: IOException in event loop: Connection reset
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl$EventCoordinatorImp.run(AbstractJavaGDSImpl.java:3234)
at java.lang.Thread.run(Thread.java:619)
Exception in thread "main" org.firebirdsql.jdbc.FBSQLException: GDS Exception. 335544726. Error reading data from the connection.
null
at org.firebirdsql.event.FBEventManager.disconnect(FBEventManager.java:139)
at JDBC125Reproduction.main(JDBC125Reproduction.java:34)
Caused by: org.firebirdsql.gds.GDSException: Error reading data from the connection.
null
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.receiveResponse(AbstractJavaGDSImpl.java:2177)
at org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.iscCancelEvents(AbstractJavaGDSImpl.java:3136)
at org.firebirdsql.event.FBEventManager$GdsEventHandler.unregister(FBEventManager.java:429)
at org.firebirdsql.event.FBEventManager.unregisterListener(FBEventManager.java:400)
at org.firebirdsql.event.FBEventManager.disconnect(FBEventManager.java:137)
... 1 more

Maybe that was something in Java which was fixed in the meantime?

Mark Rotteveel added a comment - 17/Jul/11 08:31 AM
Retested with Java 1.6.0_26-b03 64-bit server VM on Windows 7 against Firebird 2.5.0. I am also no longer able to reproduce. I scanned the release notes between Java 6 update 18 and Java 6 update 25, but there wasn't anything that really jumped out as to be related to this.

Will close this ticket as unable to reproduce.