Repository navigation
Closed
Labels
Known Build ErrorUse this to report build issues in the .NET Helix tabarch-x86area-System.IOin-prThere is an active PR which will close this issue when it is mergedos-windowsruntime-coreclrspecific to the CoreCLR runtime
Milestone
Description
Error Blob
{
"ErrorMessage": "at System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_Directory_Delete_MultipleFilters",
"BuildRetry": true,
"ErrorPattern": "",
"ExcludeConsoleLog": false
}Reproduction Steps
- Found in unrelated 7.0 PR: [release/7.0-staging] Update SqlClient and ship Microsoft.Windows.Compatibility #97883
- Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=551129
- Queue:
Libraries Test Run checked coreclr windows x86 Debug - Job results: https://dev.azure.com/dnceng-public/public/_build/results?buildId=551129&view=logs&j=215a953c-1e4b-5cc0-95e2-5484aabbe659&t=312e0115-80c6-5d8d-a731-029b3098bcf6
- Log file: https://helixre107v0xd1eu3ibi6ka.blob.core.windows.net/dotnet-runtime-refs-pull-97883-merge-de8975dcd8f044af9b/System.IO.FileSystem.Watcher.Tests/1/console.87568cb0.log?helixlogtype=result
- Output:
===========================================================================================================
C:\h\w\C0550A4F\w\A85A0959\e>"C:\h\w\C0550A4F\p\dotnet.exe" exec --runtimeconfig System.IO.FileSystem.Watcher.Tests.runtimeconfig.json --depsfile System.IO.FileSystem.Watcher.Tests.deps.json xunit.console.dll System.IO.FileSystem.Watcher.Tests.dll -xml testResults.xml -nologo -nocolor -notrait category=IgnoreForCI -notrait category=OuterLoop -notrait category=failing
Discovering: System.IO.FileSystem.Watcher.Tests (method display = ClassAndMethod, method display options = None)
Discovered: System.IO.FileSystem.Watcher.Tests (found 174 of 209 test cases)
Starting: System.IO.FileSystem.Watcher.Tests (parallel test collections = on, max threads = 4)
System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_Directory_Delete_MultipleFilters [FAIL]
System.IO.DirectoryNotFoundException : Could not find a part of the path 'C:\h\w\C0550A4F\t\#FileSystemWatcherTests_eq2ujqlt.lfo\FileSystemWatcher_Directory_Delete_MultipleFilters_1009_7eam6lig\FileSystemWatcher_Directory_Delete_MultipleFilters_1010_cn2nu7w1'.
Stack Trace:
/_/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs(436,0): at System.IO.FileSystem.RemoveDirectoryInternal(String fullPath, Boolean topLevel, Boolean allowDirectoryNotEmpty)
/_/src/libraries/System.Private.CoreLib/src/System/IO/FileSystem.Windows.cs(261,0): at System.IO.FileSystem.RemoveDirectory(String fullPath, Boolean recursive)
/_/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs(212,0): at System.IO.DirectoryInfo.Delete(Boolean recursive)
/_/src/libraries/System.Private.CoreLib/src/System/IO/DirectoryInfo.cs(208,0): at System.IO.DirectoryInfo.Delete()
/_/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs(1019,0): at System.IO.Tests.FileSystemWatcherTests.<>c__DisplayClass61_0.<FileSystemWatcher_Directory_Delete_MultipleFilters>b__0()
/_/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs(309,0): at System.IO.Tests.FileSystemWatcherTest.ExecuteAndVerifyEvents(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Boolean assertExpected, String[] expectedPaths, Int32 timeout)
/_/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs(198,0): at System.IO.Tests.FileSystemWatcherTest.ExpectEvent(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Action cleanup, String[] expectedPaths, Int32 attempts, Int32 timeout)
/_/src/libraries/System.IO.FileSystem.Watcher/tests/Utility/FileSystemWatcherTest.cs(168,0): at System.IO.Tests.FileSystemWatcherTest.ExpectEvent(FileSystemWatcher watcher, WatcherChangeTypes expectedEvents, Action action, Action cleanup, String expectedPath, Int32 attempts, Int32 timeout)
/_/src/libraries/System.IO.FileSystem.Watcher/tests/FileSystemWatcher.unit.cs(1019,0): at System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_Directory_Delete_MultipleFilters()
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
/_/src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs(81,0): at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
Finished: System.IO.FileSystem.Watcher.Tests
=== TEST EXECUTION SUMMARY ===
System.IO.FileSystem.Watcher.Tests Total: 327, Errors: 0, Failed: 1, Skipped: 0, Time: 10.115s
----- end Fri 02/02/2024 18:18:47.75 ----- exit code 1 ----------------------------------------------------------
Known issue validation
Build: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=551129
Error message validated: [at System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_Directory_Delete_MultipleFilters]
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 2/8/2024 11:20:36 PM UTC
Report
| Build | Definition | Test | Pull Request |
|---|---|---|---|
| 1342616 | dotnet/runtime | System.IO.FileSystem.Watcher.Tests.WorkItemExecution | #125766 |
Summary
| 24-Hour Hit Count | 7-Day Hit Count | 1-Month Count |
|---|---|---|
| 0 | 1 | 1 |
Reacted by Copilot
Metadata
Metadata
Assignees
Labels
Known Build ErrorUse this to report build issues in the .NET Helix tabarch-x86area-System.IOin-prThere is an active PR which will close this issue when it is mergedos-windowsruntime-coreclrspecific to the CoreCLR runtime
Activity
carlossanlop commentedon Feb 8, 2024
The path has
#characters. Are those allowed? Could that be the issue, @dotnet/area-system-io ?C:\h\w\C0550A4F\t\#FileSystemWatcherTests_eq2ujqlt.lfo\FileSystemWatcher_Directory_Delete_MultipleFilters_1009_7eam6lig\FileSystemWatcher_Directory_Delete_MultipleFilters_1010_cn2nu7w1jozkee commentedon Jun 25, 2024
Looks like we fixed it in 8.0 #79901. Can we backport that test fix?
[-][7.0] Could not find a part of the path in System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_Directory_Delete_MultipleFilters[/-][+]Could not find a part of the path in System.IO.Tests.FileSystemWatcherTests.FileSystemWatcher_Directory_Delete_MultipleFilters[/+]danmoseley commentedon Mar 22, 2026
Note
This analysis was generated by Copilot.
PR #79901 fixed the most common failure mode (adding cleanup lambdas to recreate directories between retries), but the test still hits occasionally — the Known Build Error report shows 1 hit in the past month. Two remaining issues likely explain the continued flakiness:
1. Windows pending-delete race (still causes
DirectoryNotFoundException)On NTFS,
RemoveDirectorymarks a directory for deletion but doesn't fully remove it until all handles are closed. The cleanup sequence can race:AV/indexers or buffered I/O could hold transient handles on the child directory, extending the pending-delete window. The cleanup's
Create()silently does nothing because Windows reports the path as still existing.Potential fix — wait for the delete to fully complete before recreating:
2.
EnableRaisingEvents→action()race (causes event to be missed, triggering retries)In
ExecuteAndVerifyEvents:EnableRaisingEventscallsReadDirectoryChangesWasynchronously. If the kernel hasn't finished setting up the watch beforeDelete()completes, the event is silently dropped. With only 3 attempts × 1s timeout, a loaded CI machine can miss all of them — which then triggers the pending-delete race in issue 1.Additionally,
RecreateWatchernever disposes the old watcher, so on retries multiple watchers hold handles on the same directory, increasing handle contention and extending pending-delete windows.Summary
Issue 2 explains why events get missed (triggering retries), and issue 1 explains why retries then fail with
DirectoryNotFoundException. A robust fix likely needs both — wait for real deletion beforeCreate(), and give the watcher time to register before acting.Fix flaky FileSystemWatcher_Directory_Delete_MultipleFilters due to W…
Fix flaky FileSystemWatcher_Directory_Delete_MultipleFilters due to W…
Fix flaky FileSystemWatcher_Directory_Delete_MultipleFilters due to W…