Potential Race Condition Fix - OS Rename & Chmod - PermissionError#115
Merged
Byron merged 2 commits intogitpython-developers:masterfrom Jan 2, 2025
DEKHTIARJonathan:patch-1
Merged
Potential Race Condition Fix - OS Rename & Chmod - PermissionError#115Byron merged 2 commits intogitpython-developers:masterfrom DEKHTIARJonathan:patch-1
Byron merged 2 commits intogitpython-developers:masterfrom
DEKHTIARJonathan:patch-1
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is a really flaky and hard to debug bug when using
gitdbat least on MacOS (M-Processor) using Docker (docker.io/python:3.13image).I have only been able to reproduce this error within
pyteston my laptop (Apple M4 laptop).I completely randomly get:
When you inspect a little bit that
obj_path- everything looks absolutely fine as far as I can tell. I have no idea what could trigger thisPermissionError. The script is executing under the userdev-user:dev-userof UID/GID:1000:1000So clearly something is not going well.
Looking a little bit more in detail, turns out the error is always happening in scenario B - but not systematically in scenario B:
There might be an interference between
tempfile.mkstemp,os.renameandos.chmod. Not sure which one.It seems like a retry loop with a small temporization seems to mitigate the problem.
One supposition is that
os.renamemight not entirely complete by the time it returns. Or some file descriptors might be corrupted. Unfortunately, it's really really hard for me to debug and I'm not sure even what to look for.