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

delete file race condition #104

Closed
johnml1135 opened this issue Aug 31, 2023 · 0 comments
Closed

delete file race condition #104

johnml1135 opened this issue Aug 31, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@johnml1135
Copy link
Collaborator

	
{"log":"\u001B[41m\u001B[30mfail\u001B[39m\u001B[22m\u001B[49m: Microsoft.AspNetCore.Server.Kestrel[13]
      Connection id \"0HMT43IG3F4VK\", Request id \"0HMT43IG3F4VK:00000010\": An unhandled exception was thrown by the application.
      SIL.DataAccess.DuplicateKeyException: The inserted/updated entity has the same key as an existing entity.
         at SIL.DataAccess.MongoRepository`1.TryCatchDuplicate[TR](Func`1 func) in /app/src/SIL.DataAccess/MongoRepository.cs:line 242
         at SIL.DataAccess.MongoRepository`1.InsertAsync(T entity, CancellationToken cancellationToken) in /app/src/SIL.DataAccess/MongoRepository.cs:line 72
         at Serval.DataFiles.Services.DataFileService.DeleteAsync(String id, CancellationToken cancellationToken) in /app/src/Serval.DataFiles/Services/DataFileService.cs:line 123
         at Serval.DataFiles.Controllers.DataFilesController.DeleteAsync(String id, CancellationToken cancellationToken) in /app/src/Serval.DataFiles/Controllers/DataFilesController.cs:line 211
         at lambda_method164(Closure , Object )
         at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ExceptionContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
         at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
         at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
","stream":"stdout","time":"2023-08-31T08:40:07.663424153Z","type":"fail","source":"Microsoft.AspNetCore.Server.Kestrel"}

There is a race condition that will cause an error if you try to delete the file twice at "nearly" the same time.

@johnml1135 johnml1135 self-assigned this Aug 31, 2023
@johnml1135 johnml1135 added the bug Something isn't working label Aug 31, 2023
@johnml1135 johnml1135 added this to the 1.1 Mother Tongue MVP milestone Aug 31, 2023
johnml1135 added a commit that referenced this issue Sep 1, 2023
johnml1135 added a commit that referenced this issue Sep 5, 2023
Add unit test
johnml1135 added a commit that referenced this issue Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: ✅ Done
Development

No branches or pull requests

1 participant