Skip to content

fix(dav): release part-file lock when an upload fails - #61863

Merged
CarlSchwan merged 1 commit into
masterfrom
fix/release-lock-failed-upload
Jul 16, 2026
Merged

fix(dav): release part-file lock when an upload fails#61863
CarlSchwan merged 1 commit into
masterfrom
fix/release-lock-failed-upload

Conversation

@solracsf

@solracsfsolracsf commented Jul 7, 2026

Copy link
Copy Markdown
Member

Summary

Directory::createFile() takes a shared lock on the target file and an exclusive lock on the <name>.upload.part path before calling File::put(), but only released them on the success path. If the upload throws or is interrupted, both locks are left behind.

A leftover exclusive part-file lock causes every later upload to the same path to fail with 423 Locked. Because it persists until the request-scoped cleanup runs, or up to the lock TTL (default 1h) if the PHP worker is killed mid-request, one failed upload can block that file for a long time. The web uploader retries 423, so it just keeps hitting the same lock.

This wraps put() in try/finally so the locks are always released.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@come-nccome-nc added this to the Nextcloud 35 milestone Jul 7, 2026

@come-nccome-nc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Is that still a draft?

Comment threadapps/dav/tests/unit/Connector/Sabre/DirectoryTest.php Outdated
@solracsf
solracsfforce-pushed the fix/release-lock-failed-upload branch from 91dfc0d to 88e6e4dCompareJuly 7, 2026 09:49
@solracsf
solracsf marked this pull request as ready for review July 7, 2026 09:49
@solracsf
solracsf requested a review from a team as a code ownerJuly 7, 2026 09:49
@solracsf
solracsf requested review from ArtificialOwl, leftybournes and salmart-dev and removed request for a teamJuly 7, 2026 09:49
@solracsfsolracsf self-assigned this Jul 7, 2026
@solracsf

Copy link
Copy Markdown
MemberAuthor

/backport to stable34

@solracsf

Copy link
Copy Markdown
MemberAuthor

/backport to stable33

@solracsf

Copy link
Copy Markdown
MemberAuthor

/backport to stable32

@susnuxsusnux added the community pull requests from community label Jul 7, 2026
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsfforce-pushed the fix/release-lock-failed-upload branch from 88e6e4d to e463fc9CompareJuly 7, 2026 14:46
Comment threadapps/dav/lib/Connector/Sabre/Directory.php
@CarlSchwan
CarlSchwan merged commit 443d90f into masterJul 16, 2026
257 of 266 checks passed
@CarlSchwan
CarlSchwan deleted the fix/release-lock-failed-upload branch July 16, 2026 04:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbugcommunitypull requests from communityfeature: davfeature: locking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@solracsf@CarlSchwan@come-nc@joshtrichards@susnux