Hi there,

I'm using solrj to send updateRequest in a for loop

for (Map<String, Object> map : maps) {
  if (map.containsKey("record_uuid")) {
    UpdateRequest updateRequest = new UpdateRequest();
    updateRequest.setAction( UpdateRequest.ACTION.COMMIT, false, false);

    SolrInputDocument doc = new SolrInputDocument();
    if (idx == 3) {
      doc.addField("id", map.get("record_uuid") + "_invalid");
    } else {
      doc.addField("id", map.get("record_uuid"));
    }
    idx++;

    // get list of user ids
    doc.addField("assertionUserId", new HashMap<String, Object>(){{
put("set", map.getOrDefault("assertionUserId", null)); }});

    // this makes sure update only succeeds when record with specified id exists
    doc.addField("_version_", 1);

    // update schema if needed
    syncDocFieldsWithSOLR(doc);
    // logger.debug("Added solr doc for record: " +
map.get("record_uuid") + " to updateRequest");
    logger.debug("Added solr doc for record: " + doc.get("id"));
    updateRequest.add(doc);

    try {
      // updateRequest.setParam("_version_", "1");
      updateRequest.setParam("failOnVersionConflicts", "false");
      UpdateResponse process = updateRequest.process(solrClient);
      System.out.println("xhk205 process = " + process.toString());
    } catch (Exception e) {
      logger.error("Failed to update solr doc, error message: " +
e.getMessage(), e);
    }
  }


There are 5 requests in total and I intentionally set the id in 3rd request
to be an invalid id so that updateRequet should fail. (This to mimic the
situation where the record to be updated no longer exists in solr).

What I expected is only the 3rd update fails and all other 4 succeeded.
Below is the log when the code is ran:

- Added solr doc for record: id=429cfa88-2e18-46b0-ab9f-f4efd9e36c3c
xhk205 process = {NOTE=the request is processed in a background stream}
- Added solr doc for record: id=5a80561b-a68d-46a3-a59b-03d267f35d0e
xhk205 process = {NOTE=the request is processed in a background stream}
- Added solr doc for record: id=ff2dcbee-9c05-491f-91a8-9f1fec348546_invalid
xhk205 process = {NOTE=the request is processed in a background stream}
- Added solr doc for record: id=baf7af1f-1525-403a-95bf-e28e432f1b12
xhk205 process = {NOTE=the request is processed in a background stream}
- Added solr doc for record: id=4ea76605-c262-409b-845e-213f11ea4e34
xhk205 process = {NOTE=the request is processed in a background stream}

2021-05-19 14:12:16,827 ERROR: [ConcurrentUpdateSolrClient] - error
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error
from server at http://localhost:8983/solr/biocache: Conflict



request:
http://localhost:8983/solr/biocache/update?commit=true&softCommit=false&waitSearcher=false&failOnVersionConflicts=false&wt=javabin&version=2
Remote error message: Document not found for update.  id=
ff2dcbee-9c05-491f-91a8-9f1fec348546_invalid
at
org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient$Runner.sendUpdateStream(ConcurrentUpdateSolrClient.java:394)
at
org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrClient$Runner.run(ConcurrentUpdateSolrClient.java:191)
        at
org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0

But the actual result is, update succeeded only for first 2 records, all
other 3 failed!

When I ran the query on solr admin console
http://localhost:8983/solr/biocache/select?fq=hasUserAssertions:true&q=*:*
(hasUserAssertions is a filed in the update, I removed some addField in
above code to make it looks clean)
there are only 2 records returned (the first 2)

Is it because the 3rd update caused an exception that all subsequet request
failed? I'm using solr 8.5.1 and solrj 8.8.2



Thanks

Reply via email to