Error in executing bulk Update in Cloudant CouchDB using Ektorp ExecuteBulk () and ExecuteAllOrNothing () API

858 Views Asked by At

I am facing an issue with Bulk Update on a list of documents in Cloudant DB (CouchDB) using Ektorp executeBulk & ExecuteAllOrNothing functions.

For couchDbConnector.executeAllOrNothing(List<?> list), I am getting error as follows:

org.ektorp.DbAccessException: 417:Expectation Failed
URI: /let-ut-app/_bulk_docs
Response Body: 
null
    at org.ektorp.http.StdResponseHandler.createDbAccessException(StdResponseHandler.java:44)
    at org.ektorp.http.StdResponseHandler.error(StdResponseHandler.java:62)
    at org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:98)
    at org.ektorp.http.RestTemplate.post(RestTemplate.java:61)
    at org.ektorp.impl.StdCouchDbConnector.executeBulk(StdCouchDbConnector.java:536)
    at org.ektorp.impl.StdCouchDbConnector.executeAllOrNothing(StdCouchDbConnector.java:494)

and if I change the same logic to use executeBulk as couchDbConnector.executeBulk(List<?> list) the error message became like the following:

org.ektorp.DbAccessException: 500:Internal Server Error
URI: /let-ut-app/_bulk_docs
Response Body: 
{
  "error" : "case_clause",
  "reason" : "{12,11}",
  "stack" : [ "fabric_doc_update:handle_message/3", "rexi_utils:process_mailbox/6", "rexi_utils:recv/6", "fabric_doc_update:go/3", "fabric:update_docs/3", "chttpd_db:db_req/2", "chttpd:handle_request/1", "mochiweb_http:headers/5" ]
}
    at org.ektorp.http.StdResponseHandler.createDbAccessException(StdResponseHandler.java:44)
    at org.ektorp.http.StdResponseHandler.error(StdResponseHandler.java:62)
    at org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:98)
    at org.ektorp.http.RestTemplate.post(RestTemplate.java:61)
    at org.ektorp.impl.StdCouchDbConnector.executeBulk(StdCouchDbConnector.java:536)
    at org.ektorp.impl.StdCouchDbConnector.executeBulk(StdCouchDbConnector.java:498)

Please let me know if anyone of you has come accross this issue and how you have solved it.

Appreciate your help.

Thanx much!

1

There are 1 best solutions below

0
On

I see similar with the cloudant server(s). I make the call directly using rest client:

Unfortunately this code snippet does not handle the 2 options to bulk save (uuids and all or none). You can look at the couchrest code and implement yourself (but I have not done this).

# this couchrest will throw an exception on some couchdb servers
# db.bulk_save(design_docs, false, true) # no uuids, all or nothing

bulk_docs = {'docs' => design_docs}
responses = CouchRest.post("#{db.root}/_bulk_docs", bulk_docs)