Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
http://api.drupal.org/api/function/image_style_generate/7
if (!$lock_acquired) {
// Tell client to retry again in 3 seconds. Currently no browsers are known
// to support Retry-After.
drupal_add_http_header('Status', '503 Service Unavailable');
drupal_add_http_header('Retry-After', 3);
print t('Image generation in progress. Try again shortly.');
drupal_exit();
This just looks like it should be a lock_wait(), especially since it apparently relies on behaviour that no browser actually supports.
Comment | File | Size | Author |
---|---|---|---|
#15 | image_503_fix-848044-15.patch | 653 bytes | randallknutson |
#9 | 848044.image_.patch | 2.82 KB | Anonymous (not verified) |
#7 | image.lock_.wait_.patch | 4.71 KB | Anonymous (not verified) |
#5 | image.lock_.wait_.patch | 4.1 KB | Anonymous (not verified) |
#2 | image.lock_.wait_.patch | 2.77 KB | Anonymous (not verified) |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedyep, i agree with catch.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedhere's a patch for that. code in the patch tries to acquire the lock 10 times, then gives up and sends a "Serve Error" header.
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedok, that fails because we no longer bail out and send a useless header if we don't get the lock first time.
i could just take that test out, but i want to replace it with something that tests the "another process is rebuilding so we failed to get the lock, but then we got the cache so its all good" scenario.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedhere's a patch without the test that relied on the old behaviour.
its hard to test the lock wait code without async http requests, so i've created this issue: #850782: allow testing lock code via async http calls.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous commentedtake out the lock check in the test, as we don't create one anymore.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedif ($lock_acquired === TRUE) {
is usually too verbose. I didn't look into the logic completely though.A nice to have enhancement would be http headers like 'Image wait' and 'Image build' like we do for cache misses and builds at #802446: Cache stampede protection: drupal_render() and page cache.
Comment #9
Anonymous (not verified) CreditAttribution: Anonymous commentedupdated #7 so it applies to HEAD.
Comment #11
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #12
mikran CreditAttribution: mikran commented#7: image.lock_.wait_.patch queued for re-testing.
Comment #13
mikran CreditAttribution: mikran commentedOops, I didn't mean to change anything or actually even re-test the old patch so reverting the status back.
Comment #14
Marco Vervoort CreditAttribution: Marco Vervoort commentedI encountered this bug when using the media plugin with CKEditor to insert a new thumbnail of an image into a text. On IE11 this resulted in an 'image not loaded' cross (not always, but more than 50% of the time). The randomness is probably related to timing issues (with the Developer console open the percentage dropped to about 30%).
To be quite honest, it is a bit strange that the first request for a not-yet-existing thumbnail yields a 'HTTP 200' response (albeit after a possibly lengthy delay), and that subsequent requests yield an immediate 'HTTP 503' response (as long as the image is still being generated). It doesn't feel consistent. Does anybody know whether this behaviour was intended, and if so, what the reason was?
In order to solve my immediate problem while changing as little as possible, I've modified image.module so that the code waits 3 seconds for the image to appear, by adding
This feelds like it shouldn't have negative side-effects. But an official patch to resolve this issue more thoroughly would be appreciated.
Comment #15
randallknutson CreditAttribution: randallknutson commentedRan into this as well with the media module and ckeditor. It has something to do with IE seeing the image twice and requesting it too quickly. The easiest patch is to fix this response with the code from #14. I made a patch so it can be applied in a make file.