Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncKeyLock fails intermittently. #118

Closed
JimBobSquarePants opened this issue Sep 4, 2020 · 2 comments
Closed

AsyncKeyLock fails intermittently. #118

JimBobSquarePants opened this issue Sep 4, 2020 · 2 comments
Milestone

Comments

@JimBobSquarePants
Copy link
Member

JimBobSquarePants commented Sep 4, 2020

I've seen this pop up a few times intermittently during testing. I'm more than a little concerned that this means our AsyncKeyLock does not do what it should which is to prevent cache reads while writing.

I'm gonna need help here investigating. Tests explicitly use a single instance of the server and cache and it always works on my machine.

cc/ @kroymann @sebastienros

A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:11.2043310]     CanProcessAndResolveImage(url: "http://localhost/azure/SubFolder/imagesharp-logo.p"...) [FAIL]
  X CanProcessAndResolveImage(url: "http://localhost/azure/SubFolder/imagesharp-logo.p"...) [577ms]
  Error Message:
   System.IO.IOException : The process cannot access the file 'D:\a\ImageSharp.Web\ImageSharp.Web\artifacts\bin\tests\ImageSharp.Web.Tests\Release\netcoreapp3.1\is-cache\b\2\d\5\5\2\9\b\f\e\c\d\b2d5529bfecd.png' because it is being used by another process.
  Stack Trace:
     at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
   at System.IO.File.Create(String path)
   at SixLabors.ImageSharp.Web.Caching.PhysicalFileSystemCache.SetAsync(String key, Stream stream, ImageCacheMetadata metadata) in /_/src/ImageSharp.Web/Caching/PhysicalFileSystemCache.cs:line 128
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext context, IImageResolver sourceImageResolver, ImageContext imageContext, IDictionary`2 commands) in /_/src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs:line 306
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.ProcessRequestAsync(HttpContext context, IImageResolver sourceImageResolver, ImageContext imageContext, IDictionary`2 commands) in /_/src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs:line 318
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext context) in /_/src/ImageSharp.Web/Middleware/ImageSharpMiddleware.cs:line 215
   at Microsoft.AspNetCore.TestHost.HttpContextBuilder.<>c__DisplayClass23_0.<<SendAsync>g__RunRequestAsync|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.TestHost.ClientHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at SixLabors.ImageSharp.Web.Tests.Processing.PhysicalFileSystemCacheServerTests.CanProcessAndResolveImage(String url) in D:\a\ImageSharp.Web\ImageSharp.Web\tests\ImageSharp.Web.Tests\Processing\PhysicalFileSystemCacheServerTests.cs:line 70
--- End of stack trace from previous location where exception was thrown ---
@JimBobSquarePants
Copy link
Member Author

I think it might have been an issue with tests but I'm not 100% sure.

d0b2e10

The tests failed twice in a row before this change and worked immediately after.

@JimBobSquarePants
Copy link
Member Author

Looks like it was definitely a test issue. New parallel tests pass without issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant