You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Fact]publicasync Task AbsoluteExpirationRelativeToNowExpiresCorrectlyAsync(){// This should be buggy but it seems to work for us: https://github.com/alastairtree/LazyCache/issues/84usingvarcache=new MemoryCache(new MemoryCacheOptions());varresult=await cache.AtomicGetOrCreateAsync("key",new MemoryCacheEntryOptions {AbsoluteExpirationRelativeToNow= TimeSpan.FromMilliseconds(20)},()=> Task.FromResult("foo"));
Assert.Equal("foo", result);result=await cache.AtomicGetOrCreateAsync("key",new MemoryCacheEntryOptions {AbsoluteExpirationRelativeToNow= TimeSpan.FromMilliseconds(20)},()=> Task.FromResult("bar"));
Assert.Equal("foo", result);await Task.Delay(TimeSpan.FromMilliseconds(21));// <-- XXX: THIS CAN TAKE LESS THAN 21 millisecondsresult=await cache.AtomicGetOrCreateAsync("key",new MemoryCacheEntryOptions {AbsoluteExpirationRelativeToNow= TimeSpan.FromMilliseconds(20)},()=> Task.FromResult("bar"));
Assert.Equal("bar", result);}
on my linux machine I get rarely 19 milliseconds instead of 21 on line XXX when measuring with Stopwatch and in that case the test fails.
I believe it would be better to use Thread.Sleep(21) instead of await Task.Delay(TimeSpan.FromMilliseconds(21)) here. So far with this change, it did not fail for me. So it may not fix the issue entirely but it may make it better.
From time to time,
AbsoluteExpirationRelativeToNowExpiresCorrectlyAsync
https://github.com/zkSNACKs/WalletWasabi/pull/6159/checks?check_run_id=3288453648 fails. I have tried to make it fail on Windows 10 and I couldn't. I tried on Linux and it seems it fails there much more often (like 1 / 1000 attempts or so).I believe we hit dotnet/runtime#45585 issue here:
on my linux machine I get rarely 19 milliseconds instead of 21 on line
XXX
when measuring withStopwatch
and in that case the test fails.I believe it would be better to use
Thread.Sleep(21)
instead ofawait Task.Delay(TimeSpan.FromMilliseconds(21))
here. So far with this change, it did not fail for me. So it may not fix the issue entirely but it may make it better.@nopara73 @molnard @lontivero WDYT?
The text was updated successfully, but these errors were encountered: