Strange DocumentAlreadyExists / VersionConflictError exceptions

(Ben Wolfson) #1

I'm getting some errors I don't really understand (unfortunately only in production, too, I can't reproduce them elsewhere)---occasionally attempts to update or insert a document will result in either a DocumentAlreadyExistsException, or a version conflict (even though I'm not setting a version explicitly).

The code I'm using to insert/update documents (using the Python api) is:,
               body={'doc': obj.to_es(), 'doc_as_upsert': True})

Where self and obj are instances of some helper classes.

Given the doc_as_upsert setting I would have thought that if the document already exists it would just be replaced (and this is what happens in the vast majority of cases), not cause an error; given that I'm not setting a version explicitly, the version conflict error seems equally inexplicable. Can anyone help me out? What's going on? Thanks!

(Ben Wolfson) #2

this continues to happen occasionally, and continues to be kind of baffling to me. Why should there be an exception for the document already existing when I explicitly say I want upsert-like behavior?

(system) #3