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

Cpu spike to 100% after stopping firebird when using FBEventManager [JDBC232] #281

Closed
firebird-issue-importer opened this issue Feb 6, 2012 · 11 comments

Comments

@firebird-issue-importer
Copy link

@firebird-issue-importer firebird-issue-importer commented Feb 6, 2012

Submitted by: Tomasz Kujalow (tkujalow)

Jira_subtask_inward JDBC125
Duplicates JDBC125

Attachments:
JDBC232Reproduction.java

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.
http://java.vm.name: Java HotSpot(TM) Client VM
java.compiler: null
java.vendor: Sun Microsystems Inc.
os.arch: x86
http://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.

Commits: 360187d

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 6, 2012

Commented by: Tomasz Kujalow (tkujalow)

My reproduction test

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 6, 2012

Modified by: Tomasz Kujalow (tkujalow)

Attachment: JDBC232Reproduction.java [ 12097 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 10, 2012

Commented by: Tomasz Kujalow (tkujalow)

I made new tests for new version 2.2 (2011-11-20) builded from cvs.
And this is the same as for version 2.1.6.

In my aplication I resolve this problem by :
1) Using Jaybird 2.2
2) Adding additional timer for testing if EventManager is working
This timer test EventManager by calling:
eventManager.waitForEvent("some_name_only_for_test", 1);
If this throw exception connection is broken, I remove them and begin new
3)Very important is remove all registered EventListeners (removeEventListener function) before removing connection.

This solved my problem with 100%cpu spike (but only for Jaybird 2.2) after stopping Firebird, but this is complicated and take a lot of time for testing this scenario.

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 12, 2012

Modified by: @mrotteveel

Link: This issue duplicates JDBC125 [ JDBC125 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Feb 12, 2012

Commented by: @mrotteveel

Seems to be same issue as JDBC125 which I closed as I could no longer reproduce it. I will look at it again

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 15, 2012

Modified by: @mrotteveel

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

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 15, 2012

Commented by: @mrotteveel

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)

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 15, 2012

Commented by: @mrotteveel

For Jaybird 2.2 (after beta-1).
Fixed problem and also improved robustness of closing connections / XdrInputStream / XdrOutputStream

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 15, 2012

Modified by: @mrotteveel

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

resolution: Fixed [ 1 ]

Fix Version: Jaybird 2.2 [ 10053 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Apr 15, 2012

Modified by: @mrotteveel

Version: Jaybird 2.1.6 [ 10285 ]

@firebird-issue-importer
Copy link
Author

@firebird-issue-importer firebird-issue-importer commented Aug 18, 2012

Modified by: @mrotteveel

status: Resolved [ 5 ] => Closed [ 6 ]

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

Successfully merging a pull request may close this issue.

None yet
2 participants