Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

try to recover from an OOM during citation index reading and fail-over to second solr core in case of unrecoverable OOM.

Michael Peter Christenc3dcbdc8d51a
diff --git a/source/net/yacy/kelondro/blob/HeapReader.java b/source/net/yacy/kelondro/blob/HeapReader.java
index ceacf2078..97faf0c82 100644
--- a/source/net/yacy/kelondro/blob/HeapReader.java
+++ b/source/net/yacy/kelondro/blob/HeapReader.java
@@ -539,7 +539,13 @@ public class HeapReader {
try {
blob = new byte[len];
} catch (final OutOfMemoryError e) {
- throw new SpaceExceededException(len, "HeapReader.get()/blob");
+ // try once again after GC
+ MemoryControl.gc(1000, "HeapReader.get()/blob");
+ try {
+ blob = new byte[len];
+ } catch (final OutOfMemoryError ee) {
+ throw new SpaceExceededException(len, "HeapReader.get()/blob");
+ }
}
this.file.readFully(blob, 0, blob.length);
diff --git a/source/net/yacy/search/index/Segment.java b/source/net/yacy/search/index/Segment.java
index 8aa736319..220597fb4 100644
--- a/source/net/yacy/search/index/Segment.java
+++ b/source/net/yacy/search/index/Segment.java
@@ -360,24 +360,29 @@ public class Segment {
this.externalHosts = new RowHandleSet(6, Base64Order.enhancedCoder, 0);
this.internalIDs = new RowHandleSet(12, Base64Order.enhancedCoder, 0);
this.externalIDs = new RowHandleSet(12, Base64Order.enhancedCoder, 0);
- if (connectedCitation()) {
- // read the references from the citation index
- ReferenceContainer<CitationReference> references;
- references = urlCitation().get(id, null);
- if (references == null) return; // no references at all
- Iterator<CitationReference> ri = references.entries();
- while (ri.hasNext()) {
- CitationReference ref = ri.next();
- byte[] hh = ref.hosthash(); // host hash
- if (ByteBuffer.equals(hh, 0, id, 6, 6)) {
- internalIDs.put(ref.urlhash());
- internal++;
- } else {
- externalHosts.put(hh);
- externalIDs.put(ref.urlhash());
- external++;
+ try {
+ if (connectedCitation()) {
+ // read the references from the citation index
+ ReferenceContainer<CitationReference> references;
+ references = urlCitation().get(id, null);
+ if (references == null) return; // no references at all
+ Iterator<CitationReference> ri = references.entries();
+ while (ri.hasNext()) {
+ CitationReference ref = ri.next();
+ byte[] hh = ref.hosthash(); // host hash
+ if (ByteBuffer.equals(hh, 0, id, 6, 6)) {
+ internalIDs.put(ref.urlhash());
+ internal++;
+ } else {
+ externalHosts.put(hh);
+ externalIDs.put(ref.urlhash());
+ external++;
+ }
}
}
+ } catch (SpaceExceededException e) {
+ // the Citation Index got too large, we ignore the problem and hope that a second solr index is attached which will take over now
+ if (Segment.this.fulltext.writeToWebgraph()) internalIDs.clear();
}
if ((internalIDs.size() == 0 || !connectedCitation()) && Segment.this.fulltext.writeToWebgraph()) {
// reqd the references from the webgraph