Feature #37530
closedAdd timeout for thumbnail generation process
0%
Description
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.
Files
Updated by Marius BÄ‚LTEANU about 2 years ago
- Target version set to Candidate for next major release
I think we should log the timeouts and make the timeout configurable.
Updated by Go MAEDA 6 months ago
- File clipboard-202405221631-vfis0.png clipboard-202405221631-vfis0.png added
- File 37530-v2.patch 37530-v2.patch added
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:
Updated by Go MAEDA 6 months ago
- File 37530-v3.patch 37530-v3.patch added
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.
config/configuration.yml.example:
# Timeout when generating thumbnails using the `convert` or `gs` command. # Timeout is set in seconds. #thumbnails_generation_timeout: 10
Updated by Go MAEDA 6 months ago
- File 37530-v4.patch 37530-v4.patch added
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)
.
Updated by Go MAEDA 6 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 settingthumbnails_generation_timeout