Skip to content

Handle new delete_pending error code when stating index unit files #8838

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

Conversation

z2oh
Copy link

@z2oh z2oh commented Jun 4, 2024

Multiple clang processes race to write out the same index file via renaming a newly generated index file ontop of the stale one. On Windows, there is a small window where the destination path is marked for deletion, and querying the file at this time would return a misleading permission_denied error (which is the Win32 error mapping from the underlying NTSTATUS code STATUS_DELETE_PENDING). An upstream change has modified the fs::status function on Windows to detect this case and return a more accurate delete_pending error code, which can be handled here as if the file is already deleted (i.e. no_such_file_or_directory).

The delete_pending error code was introduced here: llvm#90655

cc @compnerd

Multiple clang processes race to write out the same index file via renaming a newly generated index file ontop of the stale one. On Windows, there is a small window where the destination path is marked for deletion, and querying the file at this time would return a misleading `permission_denied` error (which is the Win32 error mapping from the underlying NTSTATUS code `STATUS_DELETE_PENDING`). An upstream change has modified the `fs::status` function on Windows to detect this case and return a more accurate `delete_pending` error code, which can be handled here as if the file is already deleted (i.e. `no_such_file_or_directory`)
@compnerd
Copy link
Member

compnerd commented Jun 4, 2024

CC: @bnbarham @akyrtzi

@bnbarham
Copy link

bnbarham commented Jun 4, 2024

Thanks 🙇‍♂️

@compnerd compnerd merged commit 513eac5 into swiftlang:next Jun 5, 2024
hjyamauchi added a commit to hjyamauchi/swift that referenced this pull request Jan 13, 2025
Apply the same fix as
swiftlang/llvm-project#8838 to the index
writer in swift/lib/Index/IndexRecord.cpp noting it is meant to be
merged with the IndexUnitWriter in LLVM.

This should fix intermittent permission denied errors during builds
that swiftlang/llvm-project#8838 fixes (but
missed this one).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants