Issue Details (XML | Word | Printable)

Key: JDBC-232
Type: Sub-task Sub-task
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Mark Rotteveel
Reporter: Tomasz Kujalow
Votes: 0
Watchers: 0
Operations

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

Cpu spike to 100% after stopping firebird when using FBEventManager

Created: 06/Feb/12 09:31 AM   Updated: 18/Aug/12 07:31 AM
Component/s: None
Affects Version/s: Jaybird 2.1.6
Fix Version/s: Jaybird 2.2

File Attachments: 1. Java Source File JDBC232Reproduction.java (8 kB)

Environment:
System: Windows XP 32bit SP3
Jaybird-2.1.6JDK_1.6.zip
Firebird 2.0.6 and Firebird 1.5 - latest vesions
Issue Links:
Duplicate
 


 Description  « Hide
Hello.
I also have problem with FBEventManager. This component and catching events work fine. Problem begin when server stop. CPU consumption spike to 100% (100% of one core, 50% whole my computer cpu). And never ends even after starting Firebird. I prepared reproduction test, which show it.
My output:

    Host: 127.0.0.1
    Port: 3050
Database: t:\test.gdb
    User: sysdba
Password: masterkey
java.version: 1.6.0_30
java.vm.version: 20.5-b03
java.vm.vendor: Sun Microsystems Inc.
java.vm.name: Java HotSpot(TM) Client VM
java.compiler: null
java.vendor: Sun Microsystems Inc.
os.arch: x86
os.name: Windows XP
os.version: 5.1
+-------------------------------------------
| Threads:
| [system] Reference Handler 2 P(10) A(true) I(false) D(true) <null> 0
| [system] Finalizer 3 P(8) A(true) I(false) D(true) <null> 0
| [system] Signal Dispatcher 4 P(9) A(true) I(false) D(true) sun.misc.Launcher$AppClassLoader@9cab16 0
| [system] Attach Listener 5 P(5) A(true) I(false) D(true) sun.misc.Launcher$AppClassLoader@9cab16 0
| [main] main 1 P(5) A(true) I(false) D(false) sun.misc.Launcher$AppClassLoader@9cab16 171875000
| [main] Thread-0 8 P(5) A(true) I(false) D(true) sun.misc.Launcher$AppClassLoader@9cab16 0
| [main] Thread-1 9 P(5) A(true) I(false) D(true) sun.misc.Launcher$AppClassLoader@9cab16 0
| current Thread: [main] main 1 P(5) A(true) I(false) D(false) sun.misc.Launcher$AppClassLoader@9cab16 171875000
+-------------------------------------------



-----------------------------------------
Stop now the Firebird server to see CPU spike (for thread id=9)
-1.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] ->
0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] -> 0.0[%] ->
32.327587[%] -> 98.4375[%] -> 98.41328[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 98.52217[%] -> 100.0[%] -> 98.4375[%] -> 100.0[%] ->
100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] ->
100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 100.0[%] -> 99.96309[%] -> 99.96309[%] -> 100.0[%] -> 96.98276[%] -> 98.4375[%] ->
99.96309[%] -> 96.875[%] -> 100.0[%] ->


When I show trace for thread which produces 100% cpu:

 trace= main {java.lang.Thread}org.firebirdsql.gds.impl.wire.XdrInputStream.readInt(XdrInputStream.java:187)
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl.nextOperation(AbstractJavaGDSImpl.java:2144)
org.firebirdsql.gds.impl.wire.AbstractJavaGDSImpl$EventCoordinatorImp.run(AbstractJavaGDSImpl.java:3116)
java.lang.Thread.run(Unknown Source)


I made many tests and I'm sure this bug.


 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Mark Rotteveel added a comment - 12/Feb/12 01:08 PM
Seems to be same issue as JDBC-125 which I closed as I could no longer reproduce it. I will look at it again

Mark Rotteveel added a comment - 15/Apr/12 07:32 AM
XdrInputStream does not correctly handle end of stream conditions for a single read(), and continously reads the same buffer positon (0). As a result the eventloop in EventCoordinatorImpl loops continously (which could be viewed as a busy-waiting loop)

Mark Rotteveel added a comment - 15/Apr/12 08:58 AM
For Jaybird 2.2 (after beta-1).
Fixed problem and also improved robustness of closing connections / XdrInputStream / XdrOutputStream