Riak Java client 100% CPU

Daniel Iwan iwan.daniel at gmail.com
Thu Feb 14 11:31:44 EST 2013


I see 100% CPU very regularly on one of the Riak client (v1.0.7) threads.
I think the place where it spins is connection reaper in RiakConnectionPool

I looked at it briefly and it seems that when it finds first connection
using peek but that does not expired it can spin in tight while loop.
I guess second peek() should be outside if block?

    private synchronized void doStart() {
        if (idleConnectionTTLNanos > 0) {
            idleReaper.scheduleWithFixedDelay(new Runnable() {
                public void run() {
                    RiakConnection c = available.peek();
                    while (c != null) {
                        long connIdleStartNanos = c.getIdleStartTimeNanos();
                        if (connIdleStartNanos + idleConnectionTTLNanos <
System.nanoTime()) {
                            if (c.getIdleStartTimeNanos() ==
connIdleStartNanos) {
                                // still a small window, but better than
locking
                                // the whole pool
                                boolean removed = available.remove(c);
                                if (removed) {
                                    c.close();
                                    permits.release();
                                }
                            }
                            c = available.peek();
                        }
                    }
                }
            }, idleConnectionTTLNanos, idleConnectionTTLNanos,
TimeUnit.NANOSECONDS);
        }

        state = State.RUNNING;
    }


Regards
Daniel Iwan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20130214/5b9f2636/attachment.html>


More information about the riak-users mailing list