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

OOM when master node forwards large file upload request to static node #308

Closed
mycxu opened this issue Oct 29, 2024 · 4 comments
Closed

Comments

@mycxu
Copy link
Contributor

mycxu commented Oct 29, 2024

I tried to upload a 2GB file, but when my master node forwards the upload request to the static node, the following error occurs:

Caused by: java.lang.OutOfMemoryError: Required array size too large: 2147483648 = 2147483648 - 0
	at java.base/sun.nio.ch.ChannelInputStream.readAllBytes(ChannelInputStream.java:122) ~[na:na]
	at org.springframework.util.FileCopyUtils.copyToByteArray(FileCopyUtils.java:149) ~[spring-core-6.0.12.jar:6.0.12]
	at org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile.getBytes(StandardMultipartHttpServletRequest.java:244) ~[spring-web-6.0.12.jar:6.0.12]
	at org.eclipse.jifa.server.service.impl.WorkerServiceImpl.forwardUploadRequestToStaticWorker(WorkerServiceImpl.java:215) ~[main/:na]
	at org.eclipse.jifa.server.service.impl.FileServiceImpl.handleUploadRequest(FileServiceImpl.java:233) ~[main/:na]
	at org.eclipse.jifa.server.controller.FileController.upload(FileController.java:122) ~[main/:na]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:578) ~[na:na]
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-6.0.12.jar:6.0.12]
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-6.0.12.jar:6.0.12]
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118) ~[spring-webmvc-6.0.12.jar:6.0.12]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:884) ~[spring-webmvc-6.0.12.jar:6.0.12]
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:797) ~[spring-webmvc-6.0.12.jar:6.0.12]
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-6.0.12.jar:6.0.12]
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1081) ~[spring-webmvc-6.0.12.jar:6.0.12]
	... 79 common frames omitted

I have traced the error to occur within the file.getBytes() call in the following function:
https://github.com/eclipse/jifa/blob/feb93c9bb57dab879a979dd0c5b3cbed6ae43903/server/src/main/java/org/eclipse/jifa/server/service/impl/WorkerServiceImpl.java#L212-L245
Is there a way to solve it?

@D-D-H
Copy link
Contributor

D-D-H commented Oct 30, 2024

@mycxu

Could you try to make the following change to see if the problem can be resolved?

         builder.part("file", new ByteArrayResource(file.getBytes()))

->

         builder.part("file", new MultipartFileResource(file))

@mycxu
Copy link
Contributor Author

mycxu commented Oct 30, 2024

@D-D-H
I solved it by using:

 builder.part("file", file.getReource())

Thx

@D-D-H
Copy link
Contributor

D-D-H commented Oct 30, 2024

Please feel free to submit a PR to fix it.

@mycxu
Copy link
Contributor Author

mycxu commented Oct 30, 2024

PR: #310

@mycxu mycxu closed this as completed Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants