-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
set_maintenance_mode
should use atomic write.
#162
Comments
@reitermarkus thank you for reporting this issue. |
Depends on fabiocaccamo/python-fsutil#91 |
@reitermarkus fixed in |
Thanks! Although I would remove since this can again have the same race condition and pollute user directories with temporary files. |
@reitermarkus for the temp file directory I used the same file directory to ensure that the temporary file is created on the same filesystem of the final file and guarantee atomicity of the replace operation, otherwise there is a potential risk of data corruption or loss. What do you think is best to do here? |
Given that the state can only be 0/1, maybe change to simply checking the existence instead of the contents of the file. |
The local file backend uses the same logic as the other backends. |
Python version
any
Django version
any
Package version
any
Current behavior (bug description)
set_maintenance_mode
uses normal write, i.eopen
+write
, which may result in a race condition as seen in inventree/InvenTree#6066. An emptymaintenance_mode.txt
then leads to astate value is not 0|1
error.Expected behavior
set_maintenance_mode
uses atomic write, i.e.open
+write
to temporary file, thenmv
temporary file to actual file. I'm sure there is a Python package that provides such a function.Upvote & Fund
The text was updated successfully, but these errors were encountered: