Skip to content

How do I use retry_on_conflict to resolve error "ConflictError 409" with update()? #1326

Closed
@erichaus

Description

@erichaus

I noticed that if I send too many requests in a short period, my elasticsearch update code throws a 409 ConflictError. Reading a bit into it, I noticed there is a param for update() to set the number of retry attempts, however when I tried using it, I get another error:

RequestError(400, 'action_request_validation_exception', 'Validation Failed: 1: compare and write operations can not be retried;')

How can I handle 409 ConflictError during frequent updates and/or use the retry_on_conflict param?

    thing = Thing.get(id=thing_id, ignore=404)

    if thing:
            return post.update(
                script=update_func,
                refresh=True,
                retry_on_conflict=ES_UPDATE_RETRY_COUNT,
                now=arrow.utcnow().float_timestamp,
            )
ConflictError: ConflictError(409, 'version_conflict_engine_exception', '[TtWP-la58FPHbw]: version conflict, required seqNo [8], primary term [1]. current document has seqNo [9] and primary term [1]')
(2 additional frame(s) were not displaye

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions