Page MenuHomePhabricator

Images which are too small too need thumbnailing are repeatedly purged from Squid
Closed, ResolvedPublic

Description

Author: tom

Description:
If an image is too small to need thumbnailing then every reference to it in a page causes an attempt to invalidate the (non-existent) thumbnail from any Squid caches.

The problem is that transform() in filerepo/File.php calculate the filename and URL of the thumbnail image then, if the file does not exist it calls the handler's doTransform() method to create the thumbnail. Once that returns the ThmbnailImage object it asks the squid caches to invalidate the thumbnail URL.

That breaks if doTransform() decides that the image doesn't really need thumbnailing due to it's size as it then returns a ThumbnailImage object that refers to the original file, but transform() still invalidates the thumbnail URL even though no thumbnail was created.

Because no thumbnail was created, next time the image is required we go round the whole loop again.

If as I did you have a page with hundreds or thousands of instances of a small image then every single one of those causes an attempted cache invalidation. Due to a second problem with the Squid cache invalidation logic (reported separately) each one takes about 8 seconds which causes the whole page to take many minutes or even hours to render.

My current fix (patch attached) pushes down the Squid cache invalidation into the doTransform() method so that it is only done is a new thumbnail is really created.


Version: 1.12.x
Severity: normal

Details

Reference
bz13776

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:08 PM
bzimport set Reference to bz13776.
bzimport added a subscriber: Unknown Object (MLST).

tom wrote:

Patch to stop repeated thumbnail image invalidations

Attached:

I'd really like it if the purge could still be kept in File.php