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

Avoid concurrency errors when saving cache files #565

Open
youngj opened this issue Feb 20, 2020 · 0 comments · May be fixed by #578
Open

Avoid concurrency errors when saving cache files #565

youngj opened this issue Feb 20, 2020 · 0 comments · May be fixed by #578
Assignees
Labels
Backend Python and API stuff Bug Something isn't working Good First Issue Good for newcomers

Comments

@youngj
Copy link
Contributor

youngj commented Feb 20, 2020

Some backend Python modules have functions that write cache files in the backend/data directory. However, in production it's possible that multiple Python processes could try to write the same cache file at the same time, which could cause invalid data to be stored in the file. This issue could be prevented if the cache files were written atomically, such as by writing a temporary file and then renaming it to the desired file name.

These methods include arrival_history.get_by_date, precomputed_stats.get_precomputed_stats, routeconfig.get_route_list, timetables.get_data_by_date_key, and timetables.get_date_keys .

Perhaps the similar logic in these functions could also be refactored to reduce duplicated code.

@youngj youngj added Bug Something isn't working Good First Issue Good for newcomers Backend Python and API stuff labels Feb 20, 2020
@JulianPinzaru JulianPinzaru self-assigned this Feb 20, 2020
@JulianPinzaru JulianPinzaru linked a pull request Feb 23, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Python and API stuff Bug Something isn't working Good First Issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants