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

Multipart files not deleted after upload is finished with async request #33161

Closed
ericciutaddt opened this issue Jul 8, 2024 · 3 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@ericciutaddt
Copy link

While trying to upload some Multipart files, they are actually stored as tmp files in disk during the duration of the upload and then the files should be removed automatically from this temporary directory.

The issue is that these files don't ever get deleted, and end up exhausting our free available disk space.

While debugging our code, it seems it never reaches the point where the cleanup is called:

We are using springframework version 6.1.10.

Original question in Stack Overflow: https://stackoverflow.com/questions/78701259/jetty-tmp-multipart-files-not-being-deleted-after-upload

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 8, 2024
@snicoll
Copy link
Member

snicoll commented Jul 8, 2024

@ericciutaddt unfortunately, it's hard for us to guess what could be wrong here and the SO question doesn't provide much more details. Would you be able to share a small sample that reproduces the problem? You can attach a zip to this issue or push the code to a GitHub repository.

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jul 8, 2024
@jhoeller jhoeller added the in: web Issues in web modules (web, webmvc, webflux, websocket) label Jul 8, 2024
@ericciutaddt
Copy link
Author

Here you have a super silly piece of code, but it illustrates my issue: https://github.com/ericins/spring-multipart-example/blob/main/src/main/java/com/example/demo/Controller.java
When making a request and uploading a file via this API, you can see the Multipart file is saved in your java.io.tmpdir under a jetty* folder when it begins processing the request. This should be removed after the request is finished but it persists in disk indefinitely.
As far as I understand, the cleanupMultipart() method from the DispatcherServlet should be called and clean these files, but is is never used.
Are my assumptions correct? Does it have anything to do with the async request?
I hope this clarifies it a bit. Please let me know if you have any more questions.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 9, 2024
@simonbasle simonbasle self-assigned this Jul 11, 2024
@simonbasle
Copy link
Contributor

This is definitely related to the async nature of the webmvc controller, thanks for the reproducer.

@simonbasle simonbasle added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Jul 11, 2024
@simonbasle simonbasle added this to the 6.1.12 milestone Jul 11, 2024
@snicoll snicoll changed the title Tmp Multipart files not being deleted after upload is finished Multipart files not deleted after upload is finished with async request Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants