Skip to content

Race condition when running ES delete_by_query #32184

Closed
@bsofiato

Description

@bsofiato

Description

When running the unit test associated with code search (file modules/indexer/code/indexer_test.go), I ran into the issue in the screenshot below.

image

As explained here, this is due to a racing condition where ES uses an outdated index while looking for the documents to delete. The safe approach is to ask ES to refresh the index before.

I wrote a PR that changes the behavior when trying to delete the documents of a repo. If the deletion results in a conflict, Gitea will refresh the index and retry.

P.S. ES is running inside a docker container spun by the command below:

docker run --rm --memory="4g" -p 127.0.0.1:9200:9200 -p 127.0.0.1:9300:9300 -e "discovery.type=single-node" -v "$(pwd)/data/elasticsearch:/usr/share/elasticsearch/data" docker.elastic.co/elasticsearch/elasticsearch:7.16.3

Gitea Version

0b1b403

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

I ran into this issue while running the tests inside VSCode

Database

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions