Skip to content

Puma doesn't delete tempfile when request is done #690

@bachue

Description

@bachue

Repo steps:

  1. Create a rack server like this:
require 'rubygems'
require 'rack'

gem 'puma'
require 'rack/handler/puma'

handler = ->(env) do
  p env['rack.input']
  [200, {"Content-Type" => "text/html"}, ["Hello Rack!"]]
end

Rack::Handler::Puma.run handler, :Port => 9292
  1. POST a 200MB file to the server via curl:
dd if=/dev/urandom of=/tmp/bigfile bs=102400 count=2048
curl -X POST http://0.0.0.0:9292 -F file=@/tmp/bigfile
Hello Rack!
  1. On server output, we can see the path of the tempfile:
Puma 2.11.2 starting...
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://0.0.0.0:9292
#<Tempfile:/var/folders/_p/ptzpwxgx6tg8dpb6w08l8t6j_tvbyv/T/puma20150420-43557-1uogav6>
  1. Don't shutdown the server, Just print the size of the tempfile:
du -sh /var/folders/_p/ptzpwxgx6tg8dpb6w08l8t6j_tvbyv/T/puma20150420-43557-1uogav6
200M    /var/folders/_p/ptzpwxgx6tg8dpb6w08l8t6j_tvbyv/T/puma20150420-43557-1uogav6

As you can see, if we don't shutdown the server, even the request is handled, the tempfile is still existed and occupy the disk space, which could cause the no disk space issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions