Handle transient shared-memory directory state during named mutex open/create#130061
Handle transient shared-memory directory state during named mutex open/create#130061Copilot wants to merge 6 commits into
Conversation
|
Tagging subscribers to this area: @dotnet/runtime-infrastructure |
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
| { | ||
| throw new IOException(SR.Format(SR.IO_SharedMemory_DirectoryNotOwnedByUid, directoryPath, id.Uid)); | ||
| } | ||
| if (!createIfNotExist || transientRetryCount >= TransientRetryCount) |
There was a problem hiding this comment.
@copilot Are you sure createIfNotExist condition is right here?
There was a problem hiding this comment.
You're right; that condition was too strict for the open path. EnsureDirectoryExists(..., createIfNotExist: false) still returns false immediately when the directory is actually missing, but it also needs to tolerate the transient owner/mode window when another process has already created the directory and is finishing normalization. I removed the createIfNotExist gate in 18f567c so only that transient validation case retries; real failures still throw after the bounded retry window.
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
|
|
||
| unsafe | ||
| // If the path exists, check that it's a directory | ||
| if (statResult != 0 || (fileStatus.Mode & Interop.Sys.FileTypes.S_IFDIR) == 0) |
There was a problem hiding this comment.
@copilot Simplify the code flow here, like:
if (statResult != 0)
{
...
}
// If the path exists, check that it's a directory
if ((fileStatus.Mode & Interop.Sys.FileTypes.S_IFDIR) == 0)
{
throw new IOException(SR.Format(SR.IO_SharedMemory_PathExistsButNotDirectory, directoryPath));
}
There was a problem hiding this comment.
Addressed in 0486326. The statResult != 0 path is now handled separately from the non-directory check.
| return true; | ||
| } | ||
|
|
||
| if (!RetryOnTransientPermissionFailure()) |
There was a problem hiding this comment.
@copilot Change the logic to be possitive everywhere
if (RetryOnTransientPermissionFailure())
{
continue;
}
throw new ....
There was a problem hiding this comment.
Addressed in 2e680d1. I flipped the remaining retry sites in EnsureDirectoryExists to the positive if (RetryOnTransientPermissionFailure()) { continue; } flow for consistency.
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
Co-authored-by: jkotas <6668460+jkotas@users.noreply.github.com>
MutexTests.CrossProcess_NamedMutex_ConcurrentCreateOrOpenwas failing in CI on Unix when one process observed/tmp/.dotnet*/shmbetween directory creation and final ownership/permission normalization. This change makes named mutex shared-memory directory validation tolerate that transient state instead of failing the open/create path.Directory race handling
SharedMemoryHelpers.EnsureDirectoryExistswith the same short transient retry model already used for shared-memory files.stat/validation sees a directory before the creating process has finished applying the expected owner or mode.Failure modes addressed
Scope