Feature #37530


Add timeout for thumbnail generation process

Added by Go MAEDA almost 2 years ago. Updated about 2 months ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


When Redmine::Thumbnail.generate generates thumbnails, some input files can take a very long time to generate thumbnails, causing Redmine to hang.

Today, in my environment, Redmine tried to generate a thumbnail for a particular PDF file and it took almost an hour (3,521,455ms) and finally raised an error. Because there were multiple accesses to the issue with the PDF attached, all processes of Redmine were occupied with the generation of a thumbnail. As the result, all other requests were not accepted and users could not see any page of Redmine.

Creating thumbnail failed (`convert /*****/*****.pdf[0] -thumbnail 100x100> png:-` failed with error:
convert-im6.q16: no images defined `png:-' @ error/convert.c/ConvertImageCommand/3229
Completed 404 Not Found in 3521455ms (ActiveRecord: 13.3ms | Allocations: 27136)

The attached patch sets the timeout of convert command to 10 seconds to prevent similar problems from occurring.


convert-timeout.patch (1.33 KB) convert-timeout.patch Go MAEDA, 2022-07-29 11:27
clipboard-202405221631-vfis0.png (23.1 KB) clipboard-202405221631-vfis0.png Go MAEDA, 2024-05-22 09:31
37530-v2.patch (3.7 KB) 37530-v2.patch Go MAEDA, 2024-05-22 09:42
37530-v3.patch (3.37 KB) 37530-v3.patch Go MAEDA, 2024-05-22 13:57
37530-v4.patch (3.22 KB) 37530-v4.patch Go MAEDA, 2024-05-26 04:29
Actions #1

Updated by Marius BÄ‚LTEANU almost 2 years ago

  • Target version set to Candidate for next major release

I think we should log the timeouts and make the timeout configurable.

Actions #2

Updated by Go MAEDA 2 months ago

I have updated the patch.

  • The new patch uses Timeout.timeout instead of the convert command's -limit option because I found the option does not work as I expected
  • If a timeout occurs, it will be logged
  • The timeout is configurable in the Administration > Setting > Display tab

Log of a timeout:

Creating thumbnail timed out:
Command: 'convert' '/path/to/redmine/files/2024/05/240522124321_testfile.pdf[0]' -thumbnail '200x200>' 'png:/path/to/redmine/tmp/thumbnails/04701b0c7bc60ba054f78329419b1d7f7620971d732da0d44e344693954974fd_79209045_200.thumb'

Timeout setting:

Actions #3

Updated by Go MAEDA 2 months ago

I have updated the patch.

The difference between the previous and the current version is that the timeout configuration has been moved from the Administration page to config/configuration.yml. I believe this value does not need to be on the Administration screen because the value is unlikely to need to be changed by the user.


  # Timeout when generating thumbnails using the `convert` or `gs` command.
  # Timeout is set in seconds.
  #thumbnails_generation_timeout: 10

Actions #4

Updated by Go MAEDA 2 months ago

  • Target version changed from Candidate for next major release to 6.0.0

Setting the target version to 6.0.0.

Actions #5

Updated by Go MAEDA about 2 months ago

I have updated the patch to support Windows.

The previous version uses Process.kill('TERM', pid) first and then Process.kill('KILL', pid), but it does not work on Windows because Windows does not support @Process.kill('TERM', pid).

For compatibility with Widows, I have removed Process.kill('TERM', pid).

Actions #6

Updated by Go MAEDA about 2 months ago

  • Tracker changed from Defect to Feature
  • Subject changed from Generating a thumbnail may take a long time and cause Redmine to hang to Add timeout for thumbnail generation process
  • Status changed from New to Closed
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch in r22847.

  • Thumbnail generation process times out in 10 seconds by default.
  • The timeout time can be changed in config/configuration.yml by setting thumbnails_generation_timeout

Also available in: Atom PDF