Project

General

Profile

Cannot upload large files when running under LiteSpeed (runs fine under Apache)

Added by Ben Ryves over 3 years ago

Hi,

I'm having issues with large file uploads (over 10MB or so) not uploading and saving when running Redmine under LiteSpeed on CENTOS 7.8 virtuozzo. If I switch LiteSpeed off and use Apache instead it all works fine. I can't see any relevant file size or memory limits in the LiteSpeed configuration (mostly a stock setup); where there are limits set they are in the order of gigabytes (e.g. 2GB) which I hope would not affect the ~20MB files I'm currently failing to upload.

When attempting to upload the file as an attachment or to the "files" section of a project the progress bar counts up, the upload script returns a HTTP 200 and Redmine seems happy with the file, however when I save the issue I get an error message "1 file(s) could not be saved." and I can see the file has not appeared in the files directory.

Here is what gets logged during a successful upload (around 1.6MB):

Started POST "/uploads.js?attachment_id=1&filename=room.jpg&content_type=image%2Fjpeg" for 86.152.124.26 at 2020-08-13 16:52:45 +0100
Processing by AttachmentsController#upload as JS
  Parameters: {"attachment_id"=>"1", "filename"=>"room.jpg", "content_type"=>"image/jpeg"}
  Current user: benryves (id=3)
Saving attachment '/home/redmine/redmine/files/2020/08/200813165245_room.jpg' (1688258 bytes)
  Rendering attachments/upload.js.erb
  Rendered attachments/upload.js.erb (0.5ms)
Completed 200 OK in 74ms (Views: 1.8ms | ActiveRecord: 21.2ms)

Here is what gets logged during a failed upload (around 26.7MB):

Started POST "/uploads.js?attachment_id=1&filename=news.zip&content_type=application%2Fx-zip-compressed" for 86.152.124.26 at 2020-08-13 16:51:25 +0100
Processing by AttachmentsController#upload as JS
  Parameters: {"attachment_id"=>"1", "filename"=>"news.zip", "content_type"=>"application/x-zip-compressed"}
  Current user: benryves (id=3)
  Rendering attachments/upload.js.erb
  Rendered attachments/upload.js.erb (1.1ms)
Completed 200 OK in 36ms (Views: 11.8ms | ActiveRecord: 12.3ms)

As you can see there is an important missing line in the log: no "Saving attachment". I don't "speak" Ruby, but edited app\model\attachment.rb with some additional logging and can see this:

  • files_to_final_location is still run when the upload fails
  • if @temp_file is false, so that code block never runs

Working backwards:

  • file=(incoming_file) is still run when the upload fails
  • unless incoming_file.nil? doesn't succeed, so that code block never runs

For some reason, it looks like incoming_file is invalid which means that @temp_file doesn't get assigned to and so files_to_final_location can't move the temp file to the files directory.

Unfortunately, I don't know enough Ruby to follow back further up the chain, which is why I've had to turn to this forum for guidance! Any help would be much appreciated.


Redmine 4.1.1.stable

Default administrator account changed
Attachments directory writable
Plugin assets directory writable (./public/plugin_assets)
MiniMagick available (optional)
ImageMagick convert available (optional)
ImageMagick PDF support available (optional)
Environment:
  Redmine version                4.1.1.stable
  Ruby version                   2.4.10-p364 (2020-03-31) [x86_64-linux]
  Rails version                  5.2.4.2
  Environment                    production
  Database adapter               Mysql2
  Mailer queue                   ActiveJob::QueueAdapters::AsyncAdapter
  Mailer delivery                sendmail
SCM:
  Subversion                     1.7.14
  Mercurial                      2.6.2
  Git                            2.12.0
  Filesystem                     
Redmine plugins:
  no plugin installed

Replies (1)

RE: Cannot upload large files when running under LiteSpeed (runs fine under Apache) - Added by Ben Ryves over 3 years ago

Some further details: I disabled the "ajax" uploader in public/javascripts/attachments.js by adding a false at the start of this conditional on line 139:

if (false && $.ajaxSettings.xhr().upload && inputEl.files) {

I can still upload smaller files but if I try to upload a large file I now get an application error and some meaningful information in the log file (attached).

For what it's worth, I can upload the same large file into PHP applications running on the same server, so whatever seems to be causing the issue seems to be specific to the way that Ruby or Redmine is set up.

    (1-1/1)