Fix CouchDB race conditions.