Investigate deadlock, hanging of tests in CI, whether it is CI, F# tasks, TaskSeq CE or XUnit, see also #25 #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
(see at bottom for original issue description and research)
xUnit bug, see this report
It turns out that if the following is true,
xUnit
ends up in a deadlock in CI, but not locally:Task<unit>
-returning testsThe example in xunit/xunit#2587 is given as two tasks that do a
Task.Delay(1)
, which, as we all know, will yield and pause for the length of at least one timer event (which is15.6ms
on most systems). Even though there are no shared variables, it leads to a deadlock.A good analysis is in this comment: dotnet/BenchmarkDotNet#2114 (comment).
Possibly related: dotnet/corefx#559 (i.e., that the diff between local and CI is that on CI there are simply not enough threads in the thread pool and thread starvation causes the deadlock).
Solution (for now)
There are only two possible solutions that I can think of, given that the issue isn't likely to be solved any time soon (this is not a critique, it is just a nature of this kind of problems):
async
library forIAsyncEnumerable<_>
and we really want to catch any potential parallelism issues.Original text
Trial and error approach:
dotnet test
with--blame-hang-timeout 15000ms
on the commandline in CI[<assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)>]
the tests run fineFollow up: running in "Crunch mode" (using NCrunch) for several hours using as many parallel threads as possible gives no issues.
Follow-up: the green test runs were either non parallel, or self-parallelized, still unclear. Edit: see above.
Follow up: it is not. It is an xUnit bug for their CI runner.
Follow up: CI or Windows or dotnet version on CI has nothing to do with this issue, these tests run fine.
dotnet test
configurations