helun/Ektorp — Issue #50: Multiple Ektorps Race Condition with Design Docs
Author: ryan-richt
Created: 2011-10-14 23:02:53+00:00
State: open

It appears that if you have multiple different Ektorps running in multiple separate processes (such as on a compute grid) against the same CouchDB server ....

If you are using CouchDbRepositorySupport, a race condition exists in which threads from the separate processes all try to create the same design doc for the first time, at the same time.

You could catch UCE's and use the one which was inserted before you succeeded (first).

Exception in thread "main" org.ektorp.UpdateConflictException: document update conflict: id: _design/MySecretClass rev: null
at org.ektorp.impl.StdCouchDbConnector$6.error(StdCouchDbConnector.java:235)
at org.ektorp.impl.StdCouchDbConnector$6.error(StdCouchDbConnector.java:224)
at org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:90)
at org.ektorp.http.RestTemplate.put(RestTemplate.java:34)
at org.ektorp.impl.StdCouchDbConnector.update(StdCouchDbConnector.java:223)
at org.ektorp.support.CouchDbRepositorySupport.initStandardDesignDocument(CouchDbRepositorySupport.java:246)