Forum
Kraken table setup and how to test if image optimizations occurred
Hi,
Should the base table for "perch2_kraken_jobs" be created automatically awhen I install and use the perch_kraken app? I understand that API optimizations do not appear on the kraken.io optimization history page so unsure how to check if optimization has occurred.
I ran some upload tests and got a debug message that the said
Invalid query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_scottgruber.perch2_kraken_jobs' doesn't exist and image file size are the same as when uploaded.
I'm storing images on Amazon S3 and images are being uploaded and referenced on the site correctly. I double-checked the Kraken API credentials and they are set correctly.
Here is my Diagnostic Report
Perch Runway: 2.8.8, PHP: 5.5.9-1ubuntu4.7, MySQL: 5.5.41, with PDO
Server OS: Linux, apache2handler
Installed apps: content (2.8.8), assets (2.8.8), categories (2.8.8), collection_2 (2.8.8), perch_kraken (1.0)
App runtimes: <?php $apps_list = array( 'content', 'categories', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /var/www/html/perch
PERCH_CORE: /var/www/html/perch/core
PERCH_RESFILEPATH: /var/www/html/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 250M, Max POST 250M, Memory: 256M, Total max file upload: 250M
Resource folder writeable: Yes
HTTP_HOST: scottgruber.me
DOCUMENT_ROOT: /var/www/html
REQUEST_URI: /perch/core/settings/diagnostics/
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Some other info in my diagnostics that may be related
PERCH_SSL: true
HTTPS: on
perch_kraken_api_key: ***
perch_kraken_api_secret: ***
perch_kraken_url: https://www.scottgruber.me
Here is the template code.
<img src="<perch:content type="image" id="image" label="Image" bucket="images" />" alt="<perch:content type="text" id="alt" label="Description" required="false" help="Photo alt tag" title="true" />" />
And here is the debug output when I upload an image.
Debug Message
SELECT u.*, r.* FROM perch2_users u, perch2_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='7a2b7fd8613d0e74f6093022418bcb2d' LIMIT 1
UPDATE perch2_users SET userHash='5e2f3ede36e788d9fa01feec5442a941' WHERE userID='1'
SELECT p.privKey FROM perch2_user_privileges p
SELECT * FROM (SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=1 OR userID=0 ORDER BY userID DESC) AS settings GROUP BY settingID
SELECT collectionID, collectionKey FROM perch2_collections WHERE collectionInAppMenu=1 ORDER BY collectionOrder ASC
SELECT * FROM perch2_content_regions WHERE regionID=26 LIMIT 1
SELECT * FROM perch2_pages WHERE pageID='5' LIMIT 1
SELECT * FROM perch2_content_items WHERE regionID=26 AND itemRev=1 ORDER BY itemOrder ASC
SELECT * FROM perch2_content_items WHERE regionID=26 AND itemRev=1 ORDER BY itemOrder ASC
Using template: /templates/content/image.html
INSERT INTO perch2_content_items (itemID, regionID, pageID, itemRev, itemOrder, itemJSON, itemSearch, itemUpdatedBy) SELECT itemID, regionID, pageID, 2 AS itemRev, itemOrder, itemJSON, itemSearch, '1' AS itemUpdatedBy FROM perch2_content_items WHERE regionID=26 AND itemRev=1 ORDER BY itemOrder ASC
REPLACE INTO perch2_resource_log (appID, itemFK, itemRowID, resourceID) SELECT cr.appID, cr.itemFK, c2.itemRowID, cr.resourceID FROM perch2_resource_log cr, perch2_content_items c1, perch2_content_items c2 WHERE cr.appID='content' AND cr.itemFK='itemRowID' AND cr.itemRowID=c1.itemRowID AND c1.itemID = c2.itemID AND c1.regionID=26 AND c2.regionID=26 AND c1.itemRev = 1 AND c2.itemRev = 2
SELECT itemRowID FROM perch2_content_items WHERE regionID=26 AND itemRev=2 ORDER BY itemOrder ASC
UPDATE perch2_content_items SET itemOrder=1000 WHERE itemRowID='86'
UPDATE perch2_content_regions SET regionLatestRev=2 WHERE regionID='26'
SELECT regionRev FROM perch2_content_regions WHERE regionID=26
DELETE FROM perch2_content_items WHERE regionID=26 AND itemRev!=1 AND itemRev IN (SELECT itemRev FROM (SELECT DISTINCT itemRev FROM perch2_content_items WHERE regionID=26 ORDER BY itemRev DESC LIMIT 8, 99999) AS t2)
DELETE FROM perch2_resource_log WHERE appID='content' AND itemFK='itemRowID' AND itemRowID NOT IN (SELECT itemRowID FROM perch2_content_items)
SELECT * FROM perch2_content_items WHERE regionID=26 AND itemRev=2 ORDER BY itemOrder ASC
DELETE FROM perch2_resource_log WHERE appID='content' AND itemFK='itemRowID' AND itemRowID='86'
SELECT * FROM perch2_resources WHERE resourceID='26' LIMIT 1
SELECT * FROM perch2_resources WHERE resourceAWOL=0 AND resourceParentID='26' AND resourceKey='thumb'
Resizing image... (gd, w150 h150 @2x thumb)
Array
(
[dev] =>
[url] => s3://www-scottgruber-me/images/grapes-thumb@2x.png
[callback_url] => https://www.scottgruber.me/perch/addons/apps/perch_kraken/callback/
[wait] =>
)
Array
(
[id] => 932c4d09390a7373b136080d80ba6a2a
)
INSERT INTO perch2_kraken_jobs(jobID,file_name,file_path) VALUES('932c4d09390a7373b136080d80ba6a2a','grapes-thumb@2x.png','s3://www-scottgruber-me/images/grapes-thumb@2x.png')
Invalid query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_scottgruber.perch2_kraken_jobs' doesn't exist
INSERT IGNORE INTO perch2_resources(resourceApp,resourceBucket,resourceFile,resourceKey,resourceParentID,resourceType,resourceCreated,resourceInLibrary,resourceWidth,resourceHeight,resourceTargetWidth,resourceTargetHeight,resourceDensity,resourceFileSize,resourceMimeType,resourceTitle) VALUES('content','images','grapes-thumb@2x.png','thumb','26','png','2015-06-22 11:16:56','0',150,112,150,150,2,93319,'image/png','Grapes thumb@2x')
SELECT resourceID FROM perch2_resources WHERE resourceBucket='images' AND resourceFile='grapes-thumb@2x.png' LIMIT 1
INSERT IGNORE INTO perch2_resource_log(`appID`, `itemFK`, `itemRowID`, `resourceID`) VALUES('content','itemRowID',86,26),('content','itemRowID',86,14)
UPDATE perch2_content_items SET itemJSON='{\"_id\":\"21\",\"image\":{\"assetID\":\"26\",\"title\":\"Grapes\",\"_default\":\"https:\\/\\/dtpytik42o9dr.cloudfront.net\\/images\\/grapes.png\",\"bucket\":\"images\",\"path\":\"grapes.png\",\"size\":1405001,\"w\":2048,\"h\":1536,\"mime\":\"image\\/png\",\"sizes\":{\"thumb\":{\"w\":150,\"h\":112,\"target_w\":150,\"target_h\":150,\"density\":2,\"path\":\"grapes-thumb@2x.png\",\"size\":93319,\"mime\":\"image\\/png\"}}},\"alt\":\"Grapes\",\"_title\":\"Grapes\"}', itemSearch=' Grapes ' WHERE itemRowID='86'
SELECT * FROM perch2_content_items WHERE regionID=26 AND itemRev=2 ORDER BY itemOrder ASC
Using template: /templates/content/image.html
UPDATE perch2_content_regions SET regionHTML='<img src=\"https://dtpytik42o9dr.cloudfront.net/images/grapes.png\" alt=\"Grapes\" />\n', regionRev=2, regionLatestRev=2 WHERE regionID='26'
Setting alert: Content successfully updated (success)
SELECT * FROM perch2_resources WHERE resourceApp='content' AND resourceInLibrary=0 AND resourceCreated<'2015-06-21 11:16:56' AND resourceID NOT IN (SELECT resourceID FROM perch2_resource_log)
SELECT MIN(itemRev) FROM perch2_content_items WHERE regionID=26
DELETE FROM perch2_content_index WHERE regionID=26 AND itemRev<0
SELECT * FROM perch2_content_items WHERE regionID=26 AND itemRev=2 ORDER BY itemOrder ASC
DELETE FROM perch2_content_index WHERE regionID=26 AND itemRev=2
Using template: /templates/content/image.html
INSERT INTO perch2_content_index (itemID, regionID, pageID, itemRev, indexKey, indexValue) VALUES (21,26,5,2,'image','https://dtpytik42o9dr.cloudfront.net/images/grapes.png'),(21,26,5,2,'alt','Grapes'),(21,26,5,2,'_id',21),(21,26,5,2,'_order','1000')
OPTIMIZE TABLE perch2_content_index
UPDATE perch2_pages SET pageModified='2015-06-22 11:16:56' WHERE pageID='5'
SELECT * FROM perch2_content_items WHERE regionID=26 AND itemRev=2 ORDER BY itemOrder ASC
Queries: 48
Memory: 5.8232
Yes, that table should be created. What do you see when you visit the Kraken app?
The table perch2_kraken_jobs was created when I visited the Perch Kraken app. (I hadn't tried to visit that page before.)
I see screen when I clicked Kraken on the Apps menu that says Recent Jobs with the following values in a table. Its status says pending and is stalled there on the automatically created thumb. Doubtful but could the @ in the file name be an issue? (I sent an email to support@kraken.io to ask just in case, but didn't see specifics on file naming rules in the kraken api docs). The image I uploaded was named santa-monica.png. Both it and the thumbnail santa-monica-thumb@2x.png get to Amazon s3.
Here is the Debug Message
I tried to upload a couple of other images (in this case named circlex.jpg. I checked and the two images were uploaded to AWS S3. In Perch when I uploaded I can see a thumb momentarily flash, but then no thumb show up in Perch Assets. Here is a screenshot of the results, which shows no thumb.
https://www.dropbox.com/s/t0swlv8whlvpnwq/assets-screenshot.jpg?dl=0
Also, no change inside the kraken app Pending Jobs.
Here is a screenshot https://www.dropbox.com/s/m7gvu14wtud5bhr/kraken-jobs-screenshot.jpg?dl=0
Have you tried with a local bucket?
Sorry, Yes, local buckets do work. Apparently stalls on the s3. Tested with 3 local uploads all 3 worked, then switched back to s3, then stalled as before. Here is a screenshot on the Kraken page.
https://www.dropbox.com/s/7bz2bcm59r24e50/kraken-local-screenshot.png?dl=0
It sounds like it could be a bug, so I'll have to file it and investigate.
With debug on, can you try adding an image to a region using a new image dimension that you've not used before?
That should then create a new image size and send it to Kraken. The parameters used are written out to the debug when you save the region.
Doing some reading on the kraken amazon s3 support page and found this.
I'm using us-west-2 region in Oregon. I'll create a new Amazon s3 instance for us-east-1 and report back.
I see now in the Perch docs:
Is there a way to set which region Perch points to if not the default? If not maybe add a value in the array or something like it for Perch 2.9.
As an aside, I went with us-west-2 because its closer to my web server host and sustainably powered with a 100% carbon neutral infrastructure. aws and sustainability
Are images otherwise going onto S3 and working? If so that's probably not the cause.
Thanks Drew.
Yes, they are getting to s3. I'm using CloudFront btw, but here is a pic I uploaded.
https://s3-us-west-2.amazonaws.com/www-scottgruber-me/images/image.jpg
That's a very nice picture.
Any luck with that debug?
Hmm.
Tested with two s3 buckets. Both tests results show up on front page, which is good, but seems like no kraken compression. Probably a low-priority bug in kraken.
One default on US Standard.
Images upload ok, but kraken_app says pending. Images do display on front page whether in an images folder or not. ex here https://s3.amazonaws.com/scottgruber-me/male-mask-thumb%402x.jpg or here https://s3.amazonaws.com/scottgruber-me/images/black-lagoon-thumb%402x.jpg
Second test back on US West-2
Images upload ok, again, kraken_app says pending. https://s3-us-west-2.amazonaws.com/www-scottgruber-me/images/black-lagoon-us-west-test-thumb%402x.jpg
link to screenshot of in kraken showing pending.
kraken-pending-screenshot.png
Can you try those debugging steps?
Sorry, just saw those debugging steps. Will do.
I created a new region in a master page called test kraken image, then uploaded 3 images on 3 pages each image at a different resolutions. All show up on the site.
Results
Here is screenshot in kraken app https://www.dropbox.com/s/35ia4e6jr332lo6/kraken-pending2-screenshot.png?dl=0
Here is the debug info for the 3 querries.
Ok, thanks, leave it with me and I'll see what I can find out.