Skip to content

Sporadic test failures are suggestive of thread-safety or state consistency problem #3

@tdg5

Description

@tdg5

Hello again!

This is kind of a follow on from #1. I don't know if any of what I report here is really a problem or not, but I wanted to make you aware of sporadic test failures that I still see that could be indicative of a bug somewhere. Maybe the race conditions only exist in the tests 🤷‍♂️ (but I have at least one data point that suggests that they are not). It could also be that the state that is causing these tests to fail is not critical state and maybe there's nothing to do.

[xUnit.net 00:00:05.27]     AsyncResourcePool.Tests.AsyncResourcePoolTests.AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed [FAIL]                                           
  X AsyncResourcePool.Tests.AsyncResourcePoolTests.AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed [7ms]                                                                    
  Error Message:
   Assert.All() Failure: 4 out of 4 items in the collection did not pass.                                                                                                                                           
[3]: Item: AsyncResourcePool.Tests.AsyncResourcePoolTests+TestResource                                                                                                                                              
     Xunit.Sdk.TrueException: Assert.True() Failure                                                                                                                                                                 
     Expected: True                                                                                                                                                                                                 
     Actual:   False                                                                                                                                                                                                
        at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95                                                                     
        at AsyncResourcePool.Tests.AsyncResourcePoolTests.<>c.<AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed>b__9_0(TestResource resource) in /home/danny/src/async-resource-pool/tests/AsyncResourcePoolTests.cs:line 268                                                                                                                                                        
        at Xunit.Assert.All[T](IEnumerable`1 collection, Action`1 action) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\CollectionAsserts.cs:line 36                                                               
[2]: Item: AsyncResourcePool.Tests.AsyncResourcePoolTests+TestResource                                                                                                                                              
     Xunit.Sdk.TrueException: Assert.True() Failure
     Expected: True                                                                                                                                                                                                 
     Actual:   False
        at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95                                                                     
        at AsyncResourcePool.Tests.AsyncResourcePoolTests.<>c.<AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed>b__9_0(TestResource resource) in /home/danny/src/async-resource-pool/tests/AsyncResourcePoolTests.cs:line 268
        at Xunit.Assert.All[T](IEnumerable`1 collection, Action`1 action) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\CollectionAsserts.cs:line 36                                                               
[1]: Item: AsyncResourcePool.Tests.AsyncResourcePoolTests+TestResource
     Xunit.Sdk.TrueException: Assert.True() Failure
     Expected: True
     Actual:   False
        at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95                                                                     
        at AsyncResourcePool.Tests.AsyncResourcePoolTests.<>c.<AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed>b__9_0(TestResource resource) in /home/danny/src/async-resource-pool/tests/AsyncResourcePoolTests.cs:line 268
        at Xunit.Assert.All[T](IEnumerable`1 collection, Action`1 action) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\CollectionAsserts.cs:line 36                                                               
[0]: Item: AsyncResourcePool.Tests.AsyncResourcePoolTests+TestResource
     Xunit.Sdk.TrueException: Assert.True() Failure
     Expected: True
     Actual:   False
        at Xunit.Assert.True(Nullable`1 condition, String userMessage) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\BooleanAsserts.cs:line 95                                                                     
        at AsyncResourcePool.Tests.AsyncResourcePoolTests.<>c.<AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed>b__9_0(TestResource resource) in /home/danny/src/async-resource-pool/tests/AsyncResourcePoolTests.cs:line 268
        at Xunit.Assert.All[T](IEnumerable`1 collection, Action`1 action) in C:\Dev\xunit\xunit\src\xunit.assert\Asserts\CollectionAsserts.cs:line 36                                                               
  Stack Trace:
     at AsyncResourcePool.Tests.AsyncResourcePoolTests.AllResourcesShouldBeDisposedAfterConnectionPoolIsDisposedOnceReusableResourceIsDisposed() in /home/danny/src/async-resource-pool/tests/AsyncResourcePoolTests.cs:line 268
--- End of stack trace from previous location where exception was thrown ---

(the number of things that fail for this test vary from 0-4 for me, it's not always 4. Most frequently there is only 1 failure in my experience)
AND

[xUnit.net 00:00:04.31]     AsyncResourcePool.Tests.AsyncResourcePoolTests.SlowDisposingResources_ShouldNotBlock [FAIL]
  X AsyncResourcePool.Tests.AsyncResourcePoolTests.SlowDisposingResources_ShouldNotBlock [1s 583ms]
  Error Message:
   Assert.Equal() Failure
Expected: Task<bool> { Status = WaitingForActivation }
Actual:   Task<bool> { Status = RanToCompletion }
  Stack Trace:
     at AsyncResourcePool.Tests.AsyncResourcePoolTests.SlowDisposingResources_ShouldNotBlock() in /home/danny/src/async-resource-pool/tests/AsyncResourcePoolTests.cs:line 329
--- End of stack trace from previous location where exception was thrown ---

I don't see these failures when I run the version of code proposed here https://github.com/extremeandy/AsyncResourcePool/pull/1/files

That's not to say "hey you should use my code!" but just a data point that suggests that the race conditions are not specific to the tests and my be indicative of a larger problem.

To produce these failures I run the tests on loop (while true; do dotnet test; sleep 1; done) and run phoronix-test-suite to produce a lot of load on my machine to exacerbate race conditions.

I am not going to look into these failures any further, but if there's any perspective or assistance I can offer, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions