Fix tests not passing on macOS with .NET Core 10#66
Conversation
|
@copilot Continue |
…tion on macOS - MiniCronTests.InMemoryLockProvider.cs Co-authored-by: jeanlrnt <63308635+jeanlrnt@users.noreply.github.com>
Fixed in commit 2632d15. The issue was a race condition in the |
There was a problem hiding this comment.
Pull request overview
This PR fixes a flaky test that was failing on macOS with .NET 10 due to a race condition caused by insufficient lock TTL (time-to-live). The test was using a 50ms TTL with 20 concurrent threads each holding locks for 10ms, causing locks to expire prematurely under certain timing/scheduling conditions specific to macOS and .NET 10.
- Increased the lock TTL from 50ms to 10 seconds in the
InMemoryJobLockProvider_ConcurrentAcquireAndRelease_ThreadSafetest - Added an explanatory comment to clarify the rationale for the longer TTL
Fixed the
InMemoryJobLockProvider_ConcurrentAcquireAndRelease_ThreadSafetest that was failing on macOS with .NET 10.Root Cause
The test used a 50ms TTL (time-to-live) for locks, but with 20 concurrent threads each holding the lock for 10ms, there was a race condition where locks could expire while threads still believed they held the lock. This was particularly problematic on macOS with .NET 10 due to different timing/scheduling behavior.
Changes Made
TimeSpan.FromMilliseconds(50)toTimeSpan.FromSeconds(10)in theInMemoryJobLockProvider_ConcurrentAcquireAndRelease_ThreadSafetestThis makes the test more robust across different platforms and .NET versions by ensuring locks don't expire during normal hold periods in the test.
Testing
The fix is minimal and surgical, addressing only the timing issue in the test without changing any production code.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.