Skip to content

Commit

Permalink
adapt SolrServerConnector.add to handle error on partial update input…
Browse files Browse the repository at this point in the history
… document.

In case of error we deleted the original document and added the new doc to the index.
This is not valid for partial update documents (which contain only a subset of the fields).
Remove the "delete" error handling step.
  • Loading branch information
reger committed Sep 13, 2015
1 parent e594130 commit b4cbdea
Showing 1 changed file with 11 additions and 2 deletions.
Expand Up @@ -216,11 +216,14 @@ public void add(final SolrInputDocument solrdoc) throws IOException, SolrExcepti
clearCaches(); // prevent further OOM if this was caused by OOM
ConcurrentLog.logException(e);
// catches "version conflict for": try this again and delete the document in advance
/*
// with possible partial update docs, don't try to delete index doc and reinsert solrdoc
// as this would result in a index doc with just the updated fields
try {
this.server.deleteById((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
} catch (final SolrServerException e1) {
ConcurrentLog.logException(e1);
}
}*/
try {
this.server.add(solrdoc, -1);
} catch (final Throwable ee) {
Expand Down Expand Up @@ -255,13 +258,17 @@ public void add(final Collection<SolrInputDocument> solrdocs) throws IOException
clearCaches(); // prevent further OOM if this was caused by OOM
ConcurrentLog.logException(e);
// catches "version conflict for": try this again and delete the document in advance
/*
// with possible partial update docs, don't try to delete index doc and reinsert solrdoc
// as this would result in a index doc with just the updated fields
List<String> ids = new ArrayList<String>();
for (SolrInputDocument solrdoc : solrdocs) ids.add((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
try {
this.server.deleteById(ids);
} catch (final SolrServerException e1) {
ConcurrentLog.logException(e1);
}
}*/
try {
this.server.commit();
} catch (final Throwable eee) {
Expand All @@ -272,6 +279,8 @@ public void add(final Collection<SolrInputDocument> solrdocs) throws IOException
this.server.add(solrdocs, -1);
} catch (final Throwable ee) {
ConcurrentLog.logException(ee);
List<String> ids = new ArrayList<String>();
for (SolrInputDocument solrdoc : solrdocs) ids.add((String) solrdoc.getFieldValue(CollectionSchema.id.getSolrFieldName()));
log.warn(e.getMessage() + " IDs=" + ids.toString());
throw new IOException(ee);
}
Expand Down

0 comments on commit b4cbdea

Please sign in to comment.