better protection against OOM during search flush and fixed missing

result push
pull/1/head
Michael Peter Christen 12 years ago
parent 221ed7d764
commit 0d7b4bc891

@ -605,7 +605,7 @@ collection=user
70_surrogates_busysleep=0 70_surrogates_busysleep=0
70_surrogates_memprereq=12582912 70_surrogates_memprereq=12582912
80_searchresult_idlesleep=10000 80_searchresult_idlesleep=10000
80_searchresult_busysleep=500 80_searchresult_busysleep=200
80_searchresult_memprereq=0 80_searchresult_memprereq=0
90_cleanup_idlesleep=300000 90_cleanup_idlesleep=300000
90_cleanup_busysleep=300000 90_cleanup_busysleep=300000

@ -417,6 +417,14 @@ public final class Fulltext {
} }
public void putDocumentLater(final SolrInputDocument doc) { public void putDocumentLater(final SolrInputDocument doc) {
if (MemoryControl.shortStatus()) {
try {
putDocument(doc);
return;
} catch (IOException ee) {
Log.logException(ee);
}
}
try { try {
this.pendingCollectionInputDocuments.put(doc); this.pendingCollectionInputDocuments.put(doc);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -434,17 +442,13 @@ public final class Fulltext {
public int processPendingInputDocuments(int count) throws IOException { public int processPendingInputDocuments(int count) throws IOException {
if (count == 0) return 0; if (count == 0) return 0;
if (count == 1) { boolean shortMemStatus = MemoryControl.shortStatus();
pendingRows2Docs(1); if (!shortMemStatus || this.pendingCollectionInputDocuments.size() < count) {
SolrInputDocument doc = this.pendingCollectionInputDocuments.poll(); pendingRows2Docs(count);
if (doc == null) return 0; }
this.putDocument(doc);
return 1;
}
pendingRows2Docs(count);
SolrInputDocument doc; SolrInputDocument doc;
Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(count); Collection<SolrInputDocument> docs = new ArrayList<SolrInputDocument>(count);
while (count-- > 0 && (doc = this.pendingCollectionInputDocuments.poll()) != null) { while ((shortMemStatus || count-- > 0) && (doc = this.pendingCollectionInputDocuments.poll()) != null) {
docs.add(doc); docs.add(doc);
} }
if (docs.size() > 0) this.putDocuments(docs); if (docs.size() > 0) this.putDocuments(docs);
@ -497,29 +501,19 @@ public final class Fulltext {
} }
public void putMetadataLater(final URIMetadataRow entry) throws IOException { public void putMetadataLater(final URIMetadataRow entry) throws IOException {
byte[] idb = entry.hash(); if (MemoryControl.shortStatus()) {
String id = ASCII.String(idb); putMetadata(entry);
return;
}
try { try {
if (this.urlIndexFile != null) this.urlIndexFile.remove(idb); this.pendingCollectionInputRows.put(entry);
// because node entries are richer than metadata entries we must check if they exist to prevent that they are overwritten } catch (InterruptedException e) {
SolrDocument sd = this.getDefaultConnector().getById(id); try {
if (sd == null || (new URIMetadataNode(sd)).isOlder(entry)) { putMetadata(entry);
SolrInputDocument doc = getDefaultConfiguration().metadata2solr(entry); } catch (IOException ee) {
try { Log.logException(ee);
this.pendingCollectionInputDocuments.put(doc); }
} catch (InterruptedException e) {
try {
putDocument(doc);
} catch (IOException ee) {
Log.logException(ee);
}
}
}
} catch (SolrException e) {
throw new IOException(e.getMessage(), e);
} }
this.statsDump = null;
if (MemoryControl.shortStatus()) clearCache();
} }
/** /**

Loading…
Cancel
Save