Altinn / altinn-studio

Next generation open source Altinn platform and applications.
https://docs.altinn.studio
BSD 3-Clause "New" or "Revised" License
111 stars 70 forks source link

File upload crashes from time to time #2044

Closed lorang92 closed 5 years ago

lorang92 commented 5 years ago

Describe the bug

Uploading an attachment regularly fails and throws an IOException: Unexpected end of Stream, the content may have already been read by another component.

No exact recipe for reproducing, but try uploading 5-10 attachments you should see the error.

To Reproduce

Steps to reproduce the behavior:

  1. Go to a service that has a file upload component\
  2. Upload attachments until you see error

Expected behavior

Should not fail

Stack trace

System.IO.IOException: Unexpected end of Stream, the content may have already been read by another component. 
   at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.DrainAsync(Stream stream, ArrayPool`1 bytePool, Nullable`1 limit, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.WebUtilities.MultipartReader.ReadNextSectionAsync(CancellationToken cancellationToken)
   at AltinnCore.Common.Helpers.FileStreamingHelper.StreamFile(HttpRequest request, Stream targetStream) in /src/AltinnCore/Common/Helpers/FileStreamingHelper.cs:line 45
   at AltinnCore.Common.Services.Implementation.DataStudioSI.SaveFormAttachment(String org, String appName, Int32 instanceOwnerId, Guid instanceId, String attachmentType, String attachmentName, HttpRequest request) in /src/AltinnCore/Common/Services/Implementation/DataStudioSI.cs:line 222
   at AltinnCore.Runtime.Controllers.InstanceController.SaveFormAttachment(String org, String service, Int32 partyId, Guid instanceId, String attachmentType, String attachmentName) in /src/AltinnCore/Runtime/Controllers/InstanceController.cs:line 485
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at System.Threading.Tasks.ValueTask`1.get_Result()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.StatusCodePagesMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Additional info

Happens both in dev (orgOwnder: tdd, service: formfill) and prod.

acn-sbuad commented 5 years ago

Moved designer and runtime to seperate nodes, and ensured that they won't be deployed to the same node n the future.

Not able to reproduse fault either in prod or dev.

jeevananthank commented 5 years ago

retest of the bug is blocked by #2074

jeevananthank commented 5 years ago

the user is getting another error which is reported in #2070. The issue reported in this bug is not seen anymore. Closing the bug.