Nosto / nosto-magento2

https://marketplace.magento.com/nosto-module-nostotagging.html
Open Software License 3.0
27 stars 26 forks source link

nosto.ERROR: Exception: Notice: unserialize(): Error at offset #652

Closed calin-ImDigital closed 4 years ago

calin-ImDigital commented 4 years ago

Magento 2 version(s) used: 2.3.4 Extension version(s) affected: 4.0.3

Description
when navigating to a product page we see this error on the latest release nosto.ERROR: Exception: Notice: unserialize(): Error at offset 65528 of 65535 bytes in /srv/releases/20200219104615/vendor/nosto/module-nostotagging/Model/Service/Product/DefaultProductSerializer.php on line 52 in /srv/releases/20200219104615/vendor/magento/framework/App/ErrorHandler.php:61 Stack trace:

0 [internal function]: Magento\Framework\App\ErrorHandler->handler(8, 'unserialize(): ...', '/srv/releases/2...', 52, Array)

1 /srv/releases/20200219104615/vendor/nosto/module-nostotagging/Model/Service/Product/DefaultProductSerializer.php(52): unserialize('O:28:"Nosto\Obj...', Array)

2 /srv/releases/20200219104615/vendor/nosto/module-nostotagging/Model/Service/Product/CachingProductService.php(104): Nosto\Tagging\Model\Service\Product\DefaultProductSerializer->fromString('O:28:"Nosto\Obj...')

3 /srv/releases/20200219104615/vendor/nosto/module-nostotagging/Model/Service/Product/SanitizingProductService.php(66): Nosto\Tagging\Model\Service\Product\CachingProductService->getProduct(Object(Magento\Catalog\Model\Product\Interceptor), Object(Magento\Store\Model\Store\Interceptor))

4 /srv/releases/20200219104615/vendor/nosto/module-nostotagging/Block/Product.php(141): Nosto\Tagging\Model\Service\Product\SanitizingProductService->getProduct(Object(Magento\Catalog\Model\Product\Interceptor), Object(Magento\Store\Model\Store\Interceptor))

5 /srv/releases/20200219104615/vendor/nosto/module-nostotagging/Block/TaggingTrait.php(71): Nosto\Tagging\Block\Product->getAbstractObject()

6 /srv/releases/20200219104615/vendor/magento/framework/View/Element/AbstractBlock.php(1099): Nosto\Tagging\Block\Product->_toHtml()

7 /srv/releases/20200219104615/vendor/magento/framework/View/Element/AbstractBlock.php(1103): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element{closure}()

8 /srv/releases/20200219104615/vendor/magento/framework/View/Element/AbstractBlock.php(673): Magento\Framework\View\Element\AbstractBlock->_loadCache()

9 /srv/releases/20200219104615/vendor/magento/framework/View/Layout.php(564): Magento\Framework\View\Element\AbstractBlock->toHtml()

10 /srv/releases/20200219104615/vendor/magento/framework/View/Layout.php(540): Magento\Framework\View\Layout->_renderBlock('nosto.product')

How to reproduce
Navigate to a product page see logs file

Magento 2 mode

Full page cache

Nosto indexer mode

fairlane commented 4 years ago

Thanks for reporting @cdiacon-img. We'll look into this asap. Meanwhile, to get rid of the error you could truncate table nosto_tagging_product_cache

calin-ImDigital commented 4 years ago

@hannunosto I did that already, but having the same issue for some products after doing that. Thanks for a quick response.

fairlane commented 4 years ago

@cdiacon-img really, that sounds really weird. Could you please contact our support and we'll continue there. We most likely need to share some data examples & merchant details.

calin-ImDigital commented 4 years ago

@hannunosto maybe you can spot the issue here it the data to unserialize Class DefaultProductSerializer method fromSting line 50

$data = 'O:28:"Nosto\Object\Product\Product":35:{s:33:"Nosto\Object\Product\Producturl";s:45:"http://example.test/myth-travel-spray.html";s:39:"Nosto\Object\Product\ProductproductId";s:5:"13216";s:34:"Nosto\Object\Product\Productname";s:17:"Myth Travel Spray";s:38:"Nosto\Object\Product\ProductimageUrl";s:77:"http://example.test/pub/media/catalog/product/e/l/ellis-myth-travel-s1.jpg";s:35:"Nosto\Object\Product\Productprice";d:30;s:39:"Nosto\Object\Product\ProductlistPrice";s:9:"30.000000";s:47:"Nosto\Object\Product\ProductpriceCurrencyCode";s:3:"USD";s:42:"Nosto\Object\Product\Productavailability";s:7:"InStock";s:40:"Nosto\Object\Product\Productcategories";O:29:"Nosto\Object\StringCollection":3:{s:40:"Nosto\Object\StringCollectionmarkupKey";s:10:"categories";s:45:"Nosto\Object\StringCollectionchildMarkupKey";s:8:"category";s:6:"*var";a:9:{i:0;s:38:"/Beauty, Home & Gifts/Beauty/Fragrance";i:1;s:25:"/Designers/Ellis Brooklyn";i:2;s:21:"/Beauty, Home & Gifts";i:3;s:36:"/Collections/Top Ten!/Top Ten Beauty";i:4;s:28:"/Beauty, Home & Gifts/Beauty";i:5;s:48:"/Beauty, Home & Gifts/Home & Gifts/Perfect Gifts";i:6;s:27:"/Mother\'s Day/Moms are Cool";i:7;s:29:"/Mother\'s Day/$100 and under!";i:8;s:45:"/Collections/What We Love/Graduation Classics";}}s:41:"Nosto\Object\Product\Productdescription";s:271:"<p dir="ltr"><span>The airy beauty of jasmine petals and tiger orchid meet the sexy, undeniable warmth of liquid musks and white cedarwood. A sophisticated myth-worthy fragrance.</span></p>
<p dir="ltr"><em>This item is not available for international shipping.</em></p>";s:35:"Nosto\Object\Product\Productbrand";N;s:41:"Nosto\Object\Product\ProductvariationId";N;s:42:"Nosto\Object\Product\ProductsupplierCost";N;s:44:"Nosto\Object\Product\ProductinventoryLevel";N;s:41:"Nosto\Object\Product\ProductreviewCount";i:0;s:41:"Nosto\Object\Product\ProductratingValue";d:0;s:48:"Nosto\Object\Product\ProductalternateImageUrls";O:29:"Nosto\Object\StringCollection":3:{s:40:"Nosto\Object\StringCollectionmarkupKey";s:20:"alternate_image_urls";s:45:"Nosto\Object\StringCollectionchildMarkupKey";s:19:"alternate_image_url";s:6:"*var";a:2:{i:0;s:77:"http://example.test/pub/media/catalog/product/e/l/ellis-myth-travel-p1.jpg";i:1;s:77:"http://example.test/pub/media/catalog/product/e/l/ellis-myth-travel-s2.jpg";}}s:39:"Nosto\Object\Product\Productcondition";N;s:36:"Nosto\Object\Product\Productgender";N;s:38:"Nosto\Object\Product\ProductageGroup";N;s:34:"Nosto\Object\Product\Productgtin";N;s:34:"Nosto\Object\Product\Producttag1";O:29:"Nosto\Object\StringCollection":3:{s:40:"Nosto\Object\StringCollectionmarkupKey";s:5:"tags1";s:45:"Nosto\Object\StringCollectionchildMarkupKey";s:3:"tag";s:6:"*var";a:1:{i:0;s:11:"add-to-cart";}}s:34:"Nosto\Object\Product\Producttag2";O:29:"Nosto\Object\StringCollection":3:{s:40:"Nosto\Object\StringCollectionmarkupKey";s:5:"tags2";s:45:"Nosto\Object\StringCollectionchildMarkupKey";s:3:"tag";s:6:"*var";a:0:{}}s:34:"Nosto\Object\Product\Producttag3";O:29:"Nosto\Object\StringCollection":3:{s:40:"Nosto\Object\StringCollectionmarkupKey";s:5:"tags3";s:45:"Nosto\Object\StringCollectionchildMarkupKey";s:3:"tag";s:6:"*var";a:0:{}}s:44:"Nosto\Object\Product\ProductgoogleCategory";N;s:48:"Nosto\Object\Product\ProductunitPricingMeasure";N;s:52:"Nosto\Object\Product\ProductunitPricingBaseMeasure";N;s:45:"Nosto\Object\Product\ProductunitPricingUnit";N;s:34:"Nosto\Object\Product\Productskus";O:34:"Nosto\Object\Product\SkuCollection":1:{s:6:"*var";a:0:{}}s:40:"Nosto\Object\Product\Productvariations";O:40:"Nosto\Object\Product\VariationCollection":1:{s:6:"*var";a:0:{}}s:38:"Nosto\Object\Product\ProductthumbUrl";N;s:42:"Nosto\Object\Product\ProductcustomFields";a:5:{s:8:"designer";s:5:"Ellis";s:9:"exclusive";s:2:"No";s:7:"newflag";s:2:"No";s:17:"same_day_shipping";s:3:"Yes";s:26:"min_available_qty_shipping";s:2:"12";}s:43:"Nosto\Object\Product\ProductdatePublished";N;s:42:"Nosto\Object\Product\ProductvarsToEncode";a:0:{}s:43:"Nosto\Object\Product\ProductautoEncodeAll";b:1;}';
fairlane commented 4 years ago

Thanks again @cdiacon-img, we'll give it a go and get back to you.

fairlane commented 4 years ago

@cdiacon-img I tried to unserialize your example data and there's was no problems. My guess is that it's related to the db collation & charset. Could you tell us the charset & collation of the db and tables in use?

Can you pleaserun these (separately) against the db in use and post here the output.

SELECT @@character_set_database, @@collation_database;
SHOW FULL COLUMNS FROM catalog_product_entity_text;
SHOW FULL COLUMNS FROM catalog_product_entity_varchar;
calin-ImDigital commented 4 years ago

@hannunosto

SELECT @@character_set_database, @@collation_database;

latin1 latin1_swedish_ci

SHOW FULL COLUMNS FROM catalog_product_entity_text;

value_id int(11) NULL NO PRI NULL auto_increment select,insert,update,references Value ID attribute_id smallint(5) unsigned NULL NO MUL 0 select,insert,update,references Attribute ID store_id smallint(5) unsigned NULL NO MUL 0 select,insert,update,references Store ID row_id int(10) unsigned NULL NO MUL NULL select,insert,update,references Version Id value text utf8_general_ci YES NULL select,insert,update,references Value

SHOW FULL COLUMNS FROM catalog_product_entity_varchar;

Field Type Collation Null Key Default Extra Privileges Comment value_id int(11) NULL NO PRI NULL auto_increment select,insert,update,references Value ID attribute_id smallint(5) unsigned NULL NO MUL 0 select,insert,update,references Attribute ID store_id smallint(5) unsigned NULL NO MUL 0 select,insert,update,references Store ID row_id int(10) unsigned NULL NO MUL NULL select,insert,update,references Version Id value varchar(255) utf8_general_ci YES NULL select,insert,update,references Value

But other then the configuration issue I can see that most of the serialized objects are truncated by the database, here is an example from "nosto_tagging_product_cache" table nosto_serialized.log

Did you actually get an unserialized object from cachingproductservice or null on this sample https://github.com/Nosto/nosto-magento2/issues/652#issuecomment-589004002, because most of the products are unserializble and not making any advantage of the caching service released on V4 version? \Nosto\Tagging\Model\Service\Product\CachingProductService::getProduct

ends on this line with "nosto.ERROR: Exception: Notice: unserialize(): Error at offset" $this->nostoLogger->exception($e);

fairlane commented 4 years ago

Thanks for the info and good point with the data getting truncated @cdiacon-img. I have a PR that addresses both of the issues here: https://github.com/Nosto/nosto-magento2/pull/653.

Feel free to checkout that branch & run bin/magento setup:upgrade. Upgrade scripts will convert the type for product_data to longtext and convert serialized data to base64 encoded string.

fairlane commented 4 years ago

This should be now fixed in 4.0.4. Please drop a comment here if 4.0.4 doesn't solve the issue.

calin-ImDigital commented 4 years ago

@hannunosto I can confirm that this fixed the issue and it looks much better 👍