Problem/Motivation

Steps to reproduce:

  • Render the same fiile twice in two different image styles
  • Upload a new file
  • Warning: filesize(): stat failed for s3://museum/new_images/89755.jpg in Drupal\Core\Image\Image->__construct() (line 54 of core/lib/Drupal/Core/Image/Image.php).
    Drupal\Core\Image\Image->__construct(Object, 's3://museum/new_images/89755.jpg') (Line: 85)
    Drupal\Core\Image\ImageFactory->get('s3://museum/new_images/89755.jpg') (Line: 280)
    Drupal\image\Entity\ImageStyle->createDerivative('s3://museum/new_images/89755.jpg', 's3://styles/thumbnail/s3/museum/new_images/89755.jpg') (Line: 118)
    Drupal\s3fs\Controller\S3fsImageStyleDownloadController->deliver(Object, 's3', Object)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
    Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
    Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
    Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
    Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
    Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
    Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
    Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
    Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 666)
    Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Proposed resolution

I believe there is some race condition triggered on the file metadata cache, but I don't fully understand yet why.
As workaround I made the cache reading get the metadata from s3, when the information isn't available locally, and then write it back.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 2996015.patch905 bytesdawehner

Comments

dawehner created an issue. See original summary.

dawehner’s picture

Status: Active » Needs review
StatusFileSize
new905 bytes

I'm really not 100% sure that this is the right fix.

cmlara’s picture

Status: Needs review » Needs work
Related issues: +#2915322: Image styles: Error generating image, missing source file.

It appears as the same functioning code except for clearstatcache(TRUE, $uri); was committed as part of the fix for #2915322: Image styles: Error generating image, missing source file..

It is unclear if the code was pulled from this issue to resolve or if it was written independently.

No root issue appeared to be discovered for why information was not in the cache to begin with.

Only remaining question would be is the clearstatcache() call still be needed. On quick glance I do not believe it should as the file should not change in the middle of operations and the cache should be fine once populated.

Setting as Needs work while that line is considered to be sure we do not have a negative impact without it.

cmlara’s picture

Status: Needs work » Fixed

Setting to fixed. I haven't seen this cause any issues without clearstatcache()

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.