René's URL Explorer Experiment


Title: Potential Race Condition Fix - OS Rename & Chmod - PermissionError by DEKHTIARJonathan · Pull Request #115 · gitpython-developers/gitdb · GitHub

Open Graph Title: Potential Race Condition Fix - OS Rename & Chmod - PermissionError by DEKHTIARJonathan · Pull Request #115 · gitpython-developers/gitdb

X Title: Potential Race Condition Fix - OS Rename & Chmod - PermissionError by DEKHTIARJonathan · Pull Request #115 · gitpython-developers/gitdb

Description: There is a really flaky and hard to debug bug when using gitdb at least on MacOS (M-Processor) using Docker (docker.io/python:3.13 image). I have only been able to reproduce this error within pytest on my laptop (Apple M4 laptop). I completely randomly get: repo = Repo(........) # Repo Created using `GitPython` [...] repo.index.add("*") ~~~~~~~~~~~~~~^^^^^ File "/usr/local/lib/python3.13/site-packages/git/index/base.py", line 885, in add entries_added.extend(self._entries_for_paths(paths, path_rewriter, fprogress, entries)) ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/git/util.py", line 176, in wrapper return func(self, *args, **kwargs) File "/usr/local/lib/python3.13/site-packages/git/index/util.py", line 111, in set_git_working_dir return func(self, *args, **kwargs) File "/usr/local/lib/python3.13/site-packages/git/index/base.py", line 745, in _entries_for_paths entries_added.append(self._store_path(filepath, fprogress)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.13/site-packages/git/index/base.py", line 698, in _store_path istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream)) File "/usr/local/lib/python3.13/site-packages/gitdb/db/loose.py", line 233, in store chmod(obj_path, self.new_objects_mode) ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ PermissionError: [Errno 1] Operation not permitted: '/git_projects//.git/objects/9d/961f54d04e15cef0e525d1cb3d937bd7b82b04' 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 this PermissionError. The script is executing under the user dev-user:dev-user of UID/GID: 1000:1000 os.getuid()=1000 pwd.getpwuid(os.getuid())=pwd.struct_passwd(pw_name='dev-user', pw_passwd='x', pw_uid=1000, pw_gid=1000, pw_gecos='', pw_dir='/home/dev-user', pw_shell='/bin/bash') os.stat(obj_path)=os.stat_result(st_mode=33152, st_ino=3713822, st_dev=65025, st_nlink=1, st_uid=1000, st_gid=1000, st_size=473, st_atime=1734989354, st_mtime=1734989354, st_ctime=1734989354) Path(obj_path).exists()=True Path(obj_path).owner()='dev-user' Path(obj_path).group()='dev-user' So 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: if isfile(obj_path): remove(tmp_path) print("SCENARIO A !!!!!!!!!!!!!!!") else: rename(tmp_path, obj_path) print("SCENARIO B !!!!!!!!!!!!!!!") There might be an interference between tempfile.mkstemp, os.rename and os.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.rename might 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.

Open Graph Description: There is a really flaky and hard to debug bug when using gitdb at least on MacOS (M-Processor) using Docker (docker.io/python:3.13 image). I have only been able to reproduce this error within pytes...

X Description: There is a really flaky and hard to debug bug when using gitdb at least on MacOS (M-Processor) using Docker (docker.io/python:3.13 image). I have only been able to reproduce this error within pytes...

Opengraph URL: https://github.com/gitpython-developers/gitdb/pull/115

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:da5316d8-9dbf-850a-5f67-db72b8c34fd5
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB910:3FCB2B:D889C3:11FB4C8:69687A59
html-safe-noncebb6a20bec47424b959330bb0fbaea1256402a0b7460cb1abdc3774a5042e7ad3
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOTEwOjNGQ0IyQjpEODg5QzM6MTFGQjRDODo2OTY4N0E1OSIsInZpc2l0b3JfaWQiOiI2Mzk1OTM3NDcyMTU0OTkxMTkzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf469b1a2593858435ad83e41fbededa802888d424746871f7d13b66b6f41605b
hovercard-subject-tagpull_request:2250142158
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/gitpython-developers/gitdb/pull/115/files
twitter:imagehttps://avatars.githubusercontent.com/u/10923599?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/10923599?s=400&v=4
og:image:altThere is a really flaky and hard to debug bug when using gitdb at least on MacOS (M-Processor) using Docker (docker.io/python:3.13 image). I have only been able to reproduce this error within pytes...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None50f46dc2d6192249fd8ebf20e76c800f4f2596d4a5f3ab63dd63a754df154f54
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/gitpython-developers/gitdb git https://github.com/gitpython-developers/gitdb.git
octolytics-dimension-user_id503709
octolytics-dimension-user_logingitpython-developers
octolytics-dimension-repository_id1126093
octolytics-dimension-repository_nwogitpython-developers/gitdb
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1126093
octolytics-dimension-repository_network_root_nwogitpython-developers/gitdb
turbo-body-classeslogged-out env-production page-responsive
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasefef287f17234b4529a4b112a3d47fe8551e32ddd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/gitpython-developers/gitdb/pull/115/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2Fgitdb%2Fpull%2F115%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgitpython-developers%2Fgitdb%2Fpull%2F115%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=gitpython-developers%2Fgitdb
Reloadhttps://github.com/gitpython-developers/gitdb/pull/115/files
Reloadhttps://github.com/gitpython-developers/gitdb/pull/115/files
Reloadhttps://github.com/gitpython-developers/gitdb/pull/115/files
gitpython-developers https://github.com/gitpython-developers
gitdbhttps://github.com/gitpython-developers/gitdb
Notifications https://github.com/login?return_to=%2Fgitpython-developers%2Fgitdb
Fork 68 https://github.com/login?return_to=%2Fgitpython-developers%2Fgitdb
Star 225 https://github.com/login?return_to=%2Fgitpython-developers%2Fgitdb
Code https://github.com/gitpython-developers/gitdb
Issues 8 https://github.com/gitpython-developers/gitdb/issues
Pull requests 0 https://github.com/gitpython-developers/gitdb/pulls
Discussions https://github.com/gitpython-developers/gitdb/discussions
Actions https://github.com/gitpython-developers/gitdb/actions
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/gitpython-developers/gitdb/security
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
Insights https://github.com/gitpython-developers/gitdb/pulse
Code https://github.com/gitpython-developers/gitdb
Issues https://github.com/gitpython-developers/gitdb/issues
Pull requests https://github.com/gitpython-developers/gitdb/pulls
Discussions https://github.com/gitpython-developers/gitdb/discussions
Actions https://github.com/gitpython-developers/gitdb/actions
Security https://github.com/gitpython-developers/gitdb/security
Insights https://github.com/gitpython-developers/gitdb/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fgitpython-developers%2Fgitdb%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fgitpython-developers%2Fgitdb%2Fissues%2Fnew%2Fchoose
Byronhttps://github.com/Byron
gitpython-developers:masterhttps://github.com/gitpython-developers/gitdb/tree/master
Conversation 21 https://github.com/gitpython-developers/gitdb/pull/115
Commits 2 https://github.com/gitpython-developers/gitdb/pull/115/commits
Checks 7 https://github.com/gitpython-developers/gitdb/pull/115/checks
Files changed 1 https://github.com/gitpython-developers/gitdb/pull/115/files
Potential Race Condition Fix - OS Rename & Chmod - PermissionError https://github.com/gitpython-developers/gitdb/pull/115/files#top
Show all changes 2 commits https://github.com/gitpython-developers/gitdb/pull/115/files
74a0eab Potential Race Condition Fix - OS Rename & Chmod DEKHTIARJonathan Dec 24, 2024 https://github.com/gitpython-developers/gitdb/pull/115/commits/74a0eabbc03209593ea1562498802359ae8a3db7
b71e273 Update gitdb/db/loose.py DEKHTIARJonathan Dec 30, 2024 https://github.com/gitpython-developers/gitdb/pull/115/commits/b71e2730c3dcab148816f0193a45550ef0a38c79
Clear filters https://github.com/gitpython-developers/gitdb/pull/115/files
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
gitdb/db/loose.pyhttps://github.com/gitpython-developers/gitdb/pull/115/files#diff-42d81ea1bcf523de4d1c8eb4f7477e0b6ba567a9255f5688bab08a1b578bdac1
View file https://github.com/gitpython-developers/gitdb/blob/b71e2730c3dcab148816f0193a45550ef0a38c79/gitdb/db/loose.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/gitpython-developers/gitdb/pull/115/{{ revealButtonHref }}
https://github.com/gitpython-developers/gitdb/pull/115/files#diff-42d81ea1bcf523de4d1c8eb4f7477e0b6ba567a9255f5688bab08a1b578bdac1
https://github.com/gitpython-developers/gitdb/pull/115/files#diff-42d81ea1bcf523de4d1c8eb4f7477e0b6ba567a9255f5688bab08a1b578bdac1
https://github.com/gitpython-developers/gitdb/pull/115/files#diff-42d81ea1bcf523de4d1c8eb4f7477e0b6ba567a9255f5688bab08a1b578bdac1
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
https://github.com/gitpython-developers/gitdb/pull/115/files#diff-42d81ea1bcf523de4d1c8eb4f7477e0b6ba567a9255f5688bab08a1b578bdac1
EliahKaganhttps://github.com/EliahKagan
Jan 4, 2025https://github.com/gitpython-developers/gitdb/pull/115/files#r1903144948
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
Byronhttps://github.com/Byron
Jan 5, 2025https://github.com/gitpython-developers/gitdb/pull/115/files#r1903215598
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
correctly calls it quadratichttps://github.com/git/git/blob/76cf4f61c87855ebf0784b88aaf737d6b09f504b/lockfile.c#L100-L102
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
EliahKaganhttps://github.com/EliahKagan
Jan 26, 2025https://github.com/gitpython-developers/gitdb/pull/115/files#r1929819772
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
GitoxideLabs/gitoxide#1815https://github.com/GitoxideLabs/gitoxide/pull/1815
#119https://github.com/gitpython-developers/gitdb/pull/119
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
https://github.com/gitpython-developers/gitdb/pull/115/files#diff-42d81ea1bcf523de4d1c8eb4f7477e0b6ba567a9255f5688bab08a1b578bdac1
Please reload this pagehttps://github.com/gitpython-developers/gitdb/pull/115/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.