Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.1dp2
-
Component/s: None
-
Security Level: Public
-
Labels:None
-
Environment:Win7, centOS 5.4, tomcat 6.x, java 1.6.x
Description
When creating one or more CouchbaseClient instances, each one appears to consume 100% of the available CPU resources per core, at least on machines I've tested.
Test case (eclipse project and ant build) included.
Also included a snapshot of my system graph on my dev machine while running the included test.
Test case (eclipse project and ant build) included.
Also included a snapshot of my system graph on my dev machine while running the included test.
-
Hide
- CouchbaseTest.zip
- 10/Nov/11 12:58 AM
- 2.25 MB
- Kurtis
-
- CouchbaseTest/.classpath 0.8 kB
- CouchbaseTest/.project 0.4 kB
- CouchbaseTest/.../org.eclipse.jdt.core.prefs 0.6 kB
- CouchbaseTest/.../CouchbaseClientTest$1.class 0.2 kB
- CouchbaseTest/.../CouchbaseClientTest$TestObject.class 0.6 kB
- CouchbaseTest/.../CouchbaseClientTest.class 4 kB
- CouchbaseTest/build.xml 1 kB
- CouchbaseTest/lib/commons-codec-1.5.jar 71 kB
- CouchbaseTest/lib/gson-1.7.1.jar 170 kB
- CouchbaseTest/lib/httpcore-4.1.3.jar 177 kB
- CouchbaseTest/lib/httpcore-nio-4.1.3.jar 193 kB
- CouchbaseTest/lib/jettison-1.3.jar 71 kB
- CouchbaseTest/lib/junit-4.8.1.jar 231 kB
- CouchbaseTest/lib/log4j-1.2.15.jar 383 kB
- CouchbaseTest/lib/netty-3.2.6.Final.jar 775 kB
- CouchbaseTest/.../spymemcached-2.8-preview3.jar 491 kB
- CouchbaseTest/log4j.properties 0.3 kB
- CouchbaseTest/.../CouchbaseClientTest.java 3 kB
-
- ViewConnection.java
- 04/May/12 9:54 AM
- 10 kB
- Alan Wood
-
- resource_usage.png
- 25 kB
- 10/Nov/11 12:58 AM
Activity
- All
- Comments
- Work Log
- History
- Activity
- Gerrit Reviews
Hide
Matt Ingenthron
added a comment -
I've reproduced this issue.
After investigating it a bit, I've found that simplifying the test to use either MemcachedClient or MembaseClient doesn't demonstrate the same issue. Under both of those, CPU usage is modest.
Further, more profiling seemed to show time on MacOS off in kqueue poll from the CouchbaseNode's run() method.
I suspect there's a thread safety issue here causing badness.
Asking Mike to review for any possible thread safety issues when there are multiple CouchbaseClients running.
After investigating it a bit, I've found that simplifying the test to use either MemcachedClient or MembaseClient doesn't demonstrate the same issue. Under both of those, CPU usage is modest.
Further, more profiling seemed to show time on MacOS off in kqueue poll from the CouchbaseNode's run() method.
I suspect there's a thread safety issue here causing badness.
Asking Mike to review for any possible thread safety issues when there are multiple CouchbaseClients running.
Show
Matt Ingenthron
added a comment - I've reproduced this issue.
After investigating it a bit, I've found that simplifying the test to use either MemcachedClient or MembaseClient doesn't demonstrate the same issue. Under both of those, CPU usage is modest.
Further, more profiling seemed to show time on MacOS off in kqueue poll from the CouchbaseNode's run() method.
I suspect there's a thread safety issue here causing badness.
Asking Mike to review for any possible thread safety issues when there are multiple CouchbaseClients running.
Hide
Mike Wiederhold
added a comment -
Were currently moving a few things around in the client. No user facing API changes, but still moving this around. I'll make sure to get this fixed as soon as possible though.
Show
Mike Wiederhold
added a comment - Were currently moving a few things around in the client. No user facing API changes, but still moving this around. I'll make sure to get this fixed as soon as possible though.
Hide
Alan Wood
added a comment -
I've put a possible fix as an attachment to this issue. It works for us, and doesn't block shutdown, other nodes, etc.
The file was also submitted here (as an alternative to the ViewNode patch placed there earlier):
http://www.couchbase.com/issues/browse/JCBC-26
The file was also submitted here (as an alternative to the ViewNode patch placed there earlier):
http://www.couchbase.com/issues/browse/JCBC-26
Hide
Steven Cooke
added a comment -
Is this still open? ViewConnection and CouchbaseConnection are both threads with tight run loops. The quick fix is to sleep(50) or so. Not sure what the real solution should be, but it seems any threaded connection to the server to get server state can be handled by a singleton.
e.g.
public void run() {
while(true) {}
}
vs
public void run() {
while (true) {
sleep(50); // utility function to hide try/catch
}
}
First will hose the CPU, second will not
e.g.
public void run() {
while(true) {}
}
vs
public void run() {
while (true) {
sleep(50); // utility function to hide try/catch
}
}
First will hose the CPU, second will not
Show
Steven Cooke
added a comment - Is this still open? ViewConnection and CouchbaseConnection are both threads with tight run loops. The quick fix is to sleep(50) or so. Not sure what the real solution should be, but it seems any threaded connection to the server to get server state can be handled by a singleton.
e.g.
public void run() {
while(true) {}
}
vs
public void run() {
while (true) {
sleep(50); // utility function to hide try/catch
}
}
First will hose the CPU, second will not
http://code.google.com/p/spymemcached/issues/detail?id=218
And this thread in the Couchbase forums:
http://www.couchbase.org/forums/thread/using-couchbaseclient-connect