loris-imageserver / loris

Loris IIIF Image Server
Other
208 stars 87 forks source link

Loris failing with no error when width is set to 500, but not at 499 or 501 or any other dimension #475

Open jeffreycwitt opened 4 years ago

jeffreycwitt commented 4 years ago

Can someone help me with this weird problem.

Loris failing with no error when width is set to 500, but not at 499 or 501 or any other dimension

So for example: This does NOT work: https://loris2.scta.info/hopkinsMSB19/Lombard_Manuscript-197.jpg/full/500,/0/default.jpg. Loris returns a blank page, without an error

Works: https://loris2.scta.info/hopkinsMSB19/Lombard_Manuscript-197.jpg/full/501,/0/default.jpg Works: https://loris2.scta.info/hopkinsMSB19/Lombard_Manuscript-197.jpg/full/499,/0/default.jpg

Any advice is much appreciated.

bcail commented 4 years ago

@jeffreycwitt is there anything in the log? What's the HTTP status code on the failing response?

alexwlchan commented 4 years ago

HTTP status code seems to be 500.

I’ve just tried in a local instance, using Lombard_Manuscript-197.jpg at full size as the original image; it works fine for me.

If I truncate the cache entry (e.g. echo '' > /cache/entry/default.jpg), I get a 500 error – I wonder if a cache has been corrupted somewhere, and Loris isn't handling that correctly?

jeffreycwitt commented 4 years ago

Alex, I was thinking it had something to do with cache, as if the cache got corrupted, and the request is never fully re-processing the image because it is going directly to the corrupted cache.

Is there an actual folder on the file system that contains the cached images? Could I shell into the server, navigate to the cache folder and delete the cached 500 width version of the image?

If so, where is the cache folder on the file system?

Best, jw

On Wed, Sep 11, 2019 at 6:56 PM Alex Chan notifications@github.com wrote:

HTTP status code seems to be 500.

I’ve just tried in a local instance, using Lombard_Manuscript-197.jpg at full size as the original image; it works fine for me.

If I truncate the cache entry (e.g. echo '' > /cache/entry/default.jpg), I get a 500 error – I wonder if a cache has been corrupted somewhere, and Loris isn't handling that correctly?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/loris-imageserver/loris/issues/475?email_source=notifications&email_token=AAIX6PLLEMFWIE4J7CBCQYTQJFZTNA5CNFSM4IVUXQN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6QEMJY#issuecomment-530597415, or mute the thread https://github.com/notifications/unsubscribe-auth/AAIX6POXPGVHYNASXPZY6NTQJFZTNANCNFSM4IVUXQNQ .

-- Dr. Jeffrey C. Witt Philosophy Department Loyola University Maryland 4501 N. Charles St. Baltimore, MD 21210 www.jeffreycwitt.com

alexwlchan commented 4 years ago

@jeffreycwitt I believe it’s whatever path you have set in img.ImageCache.cache_dp in your config file, e.g. if your config was

[img.ImageCache]
cache_dp = '/usr/local/share/loris/image_cache'

the cache directory would be /usr/local/share/loris/image_cache.

I don't know how to find this specific image in the cache off the top of my head; I'm about to get on a train so can't test right now!

alexwlchan commented 4 years ago

I’m on holiday next week so I can’t work on this then, but here are my ideas:

We add a method to ImageCache that deletes a cache entry. If we process a request and get a "not an image" error thrown from the cache, we delete the cache entry and throw the 500 error. When the user reloads, the cache gets repopulated and they get the image they want.

We could also retry the request (using something like https://pypi.org/project/tenacity/), but we want to be careful not to get stuck in an infinite retrying loop, e.g. if the source file is garbage.

jpstroop commented 4 years ago

FWIW, I once toyed with the idea of implementing a PURGE http method that you could send to the base URI to clear the cache RESTfully. Obviously it's completely non-standard, but some of the reverse proxy caches out there support something similar, I believe.

Sent via mobile. Please excuse typos and brevity.


From: Alex Chan notifications@github.com Sent: Saturday, September 21, 2019 6:34:27 PM To: loris-imageserver/loris loris@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: Re: [loris-imageserver/loris] Loris failing with no error when width is set to 500, but not at 499 or 501 or any other dimension (#475)

I’m on holiday next week so I can’t work on this then, but here are my ideas:

We add a method to ImageCache that deletes a cache entry. If we process a request and get a "not an image" error thrown from the cache, we delete the cache entry and throw the 500 error. When the user reloads, the cache gets repopulated and they get the image they want.

We could also retry the request (using something like https://pypi.org/project/tenacity/), but we want to be careful not to get stuck in an infinite retrying loop, e.g. if the source file is garbage.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/loris-imageserver/loris/issues/475?email_source=notifications&email_token=AAHUCFNLREK35WWLZZ4V5OTQK2OPHA5CNFSM4IVUXQN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7I2YUY#issuecomment-533834835, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAHUCFOLQCWXK7UJGODEKLLQK2OPHANCNFSM4IVUXQNQ.

bcail commented 4 years ago

@alexwlchan that sounds great to automatically purge an image from the cache if we know it's corrupt.