craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 635 forks source link

queue image transforms are pilling up because of missing image – but the file is not missing #7778

Closed lexislav closed 3 years ago

lexislav commented 3 years ago

Generating image transforms are pilling up and can run forever. The queue log show missing file. But the file exists, can be located on ftp and in CP on assets folder, downloaded from CP etc. The name of file varies over the log. FIles permissions seem right. The problem started propably on Mar 24 2021, but not sure about that.

2021-04-08 12:09:54 [-][-][-][error][craft\errors\VolumeObjectNotFoundException] craft\errors\VolumeObjectNotFoundException: The file "mobile_office_1.jpg" does not exist. in /vendor/craftcms/cms/src/services/AssetTransforms.php:1110
Stack trace:
#0 /vendor/craftcms/cms/src/elements/Asset.php(1411): craft\services\AssetTransforms->getLocalImageSource(Object(craft\elements\Asset))
#1 /vendor/craftcms/cms/src/services/AssetTransforms.php(1549): craft\elements\Asset->getTransformSource()
#2 /vendor/craftcms/cms/src/services/AssetTransforms.php(815): craft\services\AssetTransforms->_createTransformForAsset(Object(craft\elements\Asset), Object(craft\models\AssetTransformIndex))
#3 /vendor/craftcms/cms/src/services/AssetTransforms.php(706): craft\services\AssetTransforms->_generateTransform(Object(craft\models\AssetTransformIndex))
#4 /vendor/craftcms/cms/src/queue/jobs/GeneratePendingTransforms.php(41): craft\services\AssetTransforms->ensureTransformUrlByIndexModel(Object(craft\models\AssetTransformIndex))
#5 /vendor/yiisoft/yii2-queue/src/Queue.php(246): craft\queue\jobs\GeneratePendingTransforms->execute(Object(craft\queue\Queue))
#6 /vendor/yiisoft/yii2-queue/src/cli/Queue.php(162): yii\queue\Queue->handleMessage('613321', 'O:42:"craft\\que...', '300', '1')
#7 /vendor/yiisoft/yii2-queue/src/cli/Command.php(146): yii\queue\cli\Queue->execute('613321', 'O:42:"craft\\que...', '300', '1', '18786')
#8 [internal function]: yii\queue\cli\Command->actionExec('613321', '300', '1', '18786')
#9 /vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#10 /vendor/yiisoft/yii2/base/Controller.php(181): yii\base\InlineAction->runWithParams(Array)
#11 /vendor/yiisoft/yii2/console/Controller.php(184): yii\base\Controller->runAction('exec', Array)
#12 /vendor/yiisoft/yii2/base/Module.php(534): yii\console\Controller->runAction('exec', Array)
#13 /vendor/yiisoft/yii2/console/Application.php(181): yii\base\Module->runAction('queue/exec', Array)
#14 /vendor/craftcms/cms/src/console/Application.php(89): yii\console\Application->runAction('queue/exec', Array)
#15 /vendor/yiisoft/yii2/console/Application.php(148): craft\console\Application->runAction('queue/exec', Array)
#16 /vendor/yiisoft/yii2/base/Application.php(392): yii\console\Application->handleRequest(Object(craft\console\Request))
#17 /craft(22): yii\base\Application->run()
#18 {main}

Can't find if this is know issue with solution.

Steps to reproduce

Don't now :-/

Additional info

PHP version | 7.3.27
Linux 4.15.0-118-generic
MySQL 5.5.5
Imagick 3.4.4 (ImageMagick 6.9.7-4)
Craft Pro 3.6.11.2
2.0.41.1
v2.14.4
6.5.5

**Aliases**
@assetsBasePath | assets
brandonkelly commented 3 years ago

Can you check that file’s permissions? PHP could think a file dosen’t exist if it doesn't have permission to read it, or execute its parent folder.

lexislav commented 3 years ago

I have checked the file permissions. Was 755. The permissions of /web/assets and all its subfolders and files changed to 777 with no effect on this. Some files still marked by queue job as not found (see the log in previous post) and keep pilling up the queue jobs indefinitely.

Some other environment settings might be related?

lexislav commented 3 years ago

Additional question: is there a way to turn off those transforms (temporarily)? They seems to prioritize themselves in the queue and blocking another tasks – like formie's send notification.

brandonkelly commented 3 years ago

Do you know if any other images in the same volume are working as expected? If not, maybe the volume’s File System Path setting is incorrect. (Or if it’s set to a relative path or starts with @webroot, perhaps it’s only set correctly for web requests, but not CLI commands, or something like that.)

Additional question: is there a way to turn off those transforms (temporarily)? They seems to prioritize themselves in the queue and blocking another tasks – like formie's send notification.

You can disable them altogether from config/app.php – see https://github.com/craftcms/cms/issues/7360#issuecomment-762410501 – however I wouldn’t recommend it since {% cache %} tags won’t cache templates that contain ungenerated transform URLs. Better to fix the underlying issue.

Though I agree the jobs shouldn’t get equal priority with other more time-sensitive jobs, so I’ve just deprioritized them for the next release.

lexislav commented 3 years ago

Thanks @brandonkelly for pointing out the File system path. It was set two years ago and working just fine, until… some unknown change (in environment or in some of craft's update)

I was using alias '@assetsBasePath' => '/web/assets', and have changed it to '@assetsBasePath' => dirname(__DIR__) . '/web/assets',

The problem is gone and image transforms in queue now run smoothly. Hopefully this form would be more persistent.

brandonkelly commented 3 years ago

We just released Craft 3.6.12 with the prioritization change.