<div dir="ltr">I see 100% CPU very regularly on one of the Riak client (v1.0.7) threads.<div>I think the place where it spins is connection reaper in RiakConnectionPool</div><div><br></div><div style>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.</div>

<div style>I guess second peek() should be outside if block?</div><div><br></div><div><div>    private synchronized void doStart() {</div><div>        if (idleConnectionTTLNanos > 0) {</div><div>            idleReaper.scheduleWithFixedDelay(new Runnable() {</div>

<div>                public void run() {</div><div>                    RiakConnection c = available.peek();</div><div>                    while (c != null) {</div><div>                        long connIdleStartNanos = c.getIdleStartTimeNanos();</div>

<div>                        if (connIdleStartNanos + idleConnectionTTLNanos < System.nanoTime()) {</div><div>                            if (c.getIdleStartTimeNanos() == connIdleStartNanos) {</div><div>                                // still a small window, but better than locking</div>

<div>                                // the whole pool</div><div>                                boolean removed = available.remove(c);</div><div>                                if (removed) {</div><div>                                    c.close();</div>

<div>                                    permits.release();</div><div>                                }</div><div>                            }</div><div>                            c = available.peek();</div><div>                        } </div>

<div>                    }</div><div>                }</div><div>            }, idleConnectionTTLNanos, idleConnectionTTLNanos, TimeUnit.NANOSECONDS);</div><div>        }</div><div><br></div><div>        state = State.RUNNING;</div>

<div>    }</div><div><br></div><div><br></div><div style>Regards</div><div style>Daniel Iwan</div><div><br></div>
</div></div>