Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Fix search index race condition #10695

Merged
merged 2 commits into from
Aug 23, 2024
Merged

[5.x] Fix search index race condition #10695

merged 2 commits into from
Aug 23, 2024

Conversation

jasonvarga
Copy link
Member

This PR solves a race condition when reading and writing a Comb-driven search index.

It's possible that one request will try to read the JSON file when another is writing to it, causing the JSON parsing to return invalid JSON.

Invalid JSON would return null. Passing null to collect() would be an empty collection. If this happened when you are trying to insert something into the index, it would result in that index only containing the inserted data.

This is solved by throwing an exception when encountering invalid JSON. This would prevent the search index being emptied out but of course now results in an exception.

Additionally, file locks are now used when reading and writing those files to prevent getting into that situation where the exception would be thrown to begin with.

@jasonvarga jasonvarga merged commit e7fffc0 into 5.x Aug 23, 2024
18 checks passed
@jasonvarga jasonvarga deleted the search-index-race branch August 23, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant