Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventManager thread spikes CPU when FB shuts down [JDBC125] #166

Closed
firebird-automations opened this issue Aug 4, 2008 · 9 comments
Closed

Comments

@firebird-automations
Copy link

Submitted by: Philip Williams (unordained)

Jira_subtask_outward JDBC232
Is duplicated by JDBC232

Attachments:
JDBC125Reproduction.java

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)

@firebird-automations
Copy link
Author

Modified by: Roman Rokytskyy (rrokytskyy)

Fix Version: Jaybird 2.2 [ 10053 ]

timeestimate: 0 [ 0 ]

timeoriginalestimate: 0 [ 0 ]

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

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)

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Attachment: JDBC125Reproduction.java [ 11583 ]

@firebird-automations
Copy link
Author

Commented by: Roman Rokytskyy (rrokytskyy)

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?

@firebird-automations
Copy link
Author

Commented by: @mrotteveel

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.

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

assignee: Roman Rokytskyy [ rrokytskyy ] => Mark Rotteveel [ avalanche1979 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Fix Version: Jaybird 2.2 [ 10053 ] =>

@firebird-automations
Copy link
Author

Modified by: @mrotteveel

Link: This issue is duplicated by JDBC232 [ JDBC232 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants