the cleanup process experienced a 100% CPU load situation and the loop

did not terminate:

Occurrences: 100
at java.util.HashMap$KeyIterator.next(HashMap.java:956)
at
net.yacy.cora.protocol.ConnectionInfo.cleanup(ConnectionInfo.java:300)
at
net.yacy.cora.protocol.ConnectionInfo.cleanUp(ConnectionInfo.java:293)
at net.yacy.search.Switchboard.cleanupJob(Switchboard.java:2212)
at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
net.yacy.kelondro.workflow.InstantBusyThread.job(InstantBusyThread.java:105)
at
net.yacy.kelondro.workflow.AbstractBusyThread.run(AbstractBusyThread.java:215)

This tries to fix the problem; the problem should be monitored
pull/1/head
Michael Peter Christen 10 years ago
parent 1f5b5c0111
commit 8ff76f8682

@ -26,12 +26,10 @@
package net.yacy.cora.protocol;
import java.util.Collections;
import java.util.ConcurrentModificationException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* Information about a connection
*
@ -296,12 +294,17 @@ public class ConnectionInfo implements Comparable<ConnectionInfo> {
private static void cleanup(final Set<ConnectionInfo> connectionSet) {
final Iterator<ConnectionInfo> iter = connectionSet.iterator();
synchronized (iter) {
while (iter.hasNext()) try {
ConnectionInfo con = iter.next();
if(con.getLifetime() > staleAfterMillis) {
connectionSet.remove(con);
}
} catch (ConcurrentModificationException e) {}
while (iter.hasNext()) {
ConnectionInfo con = null;
try {
con = iter.next();
} catch (Throwable e) {break;} // this must break because otherwise there is danger that the loop does never terminates
try {
if (con.getLifetime() > staleAfterMillis) {
connectionSet.remove(con);
}
} catch (Throwable e) {continue;}
}
}
}

Loading…
Cancel
Save