magento2
magento2 copied to clipboard
[Performance] GraphQL cache issue
Preconditions and environment
- Magento version 2.4.7
- I have that issue on hyva react checkout. So to reproduce the issue, I'll use a small script in steps :
(A)
pub/graphql-cache-test.php
<?php
/**
* Public alias for the application entry point
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
use Magento\Framework\App\Bootstrap;
try {
require __DIR__ . '/../app/bootstrap.php';
} catch (\Exception $e) {
echo <<<HTML
<div style="font:12px/1.35em arial, helvetica, sans-serif;">
<div style="margin:0 0 25px 0; border-bottom:1px solid #ccc;">
<h3 style="margin:0;font-size:1.7em;font-weight:normal;text-transform:none;text-align:left;color:#2f2f2f;">
Autoload error</h3>
</div>
<p>{$e->getMessage()}</p>
</div>
HTML;
http_response_code(500);
exit(1);
}
$bootstrap = Bootstrap::create(BP, $_SERVER);
/** @var \Magento\Framework\App\Http $app */
$app = $bootstrap->createApplication(\Magento\Framework\App\Http::class);
$graphqlCache = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Framework\GraphQl\Config\Data::class);
(B)
in Magento\Framework\Config\Data
protected function initData()
{
$data = $this->cache->load($this->cacheId);
if (false === $data) {
// add debug
\Magento\Framework\App\ObjectManager::getInstance()
->get('Psr\Log\LoggerInterface')->debug("CACHE {$this->cacheId} MISS");
$data = $this->reader->read();
$this->cache->save($this->serializer->serialize($data), $this->cacheId, $this->cacheTags);
} else {
// add debug
\Magento\Framework\App\ObjectManager::getInstance()
->get('Psr\Log\LoggerInterface')->debug("CACHE {$this->cacheId} HIT");
$data = $this->serializer->unserialize($data);
}
$this->merge($data);
}
Steps to reproduce
- Upgrade Magento from 2.4.6-p4 to 2.4.7
- Make a script to test graphql cache (A)
- Add debug to monitor cache HIT/MISS (B)
- purge cache
- run script multiple times
Expected result
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA MISS
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA HIT
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA HIT
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA HIT
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA HIT
Actual result
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA MISS
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA MISS
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA MISS
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA MISS
- CACHE [prefix]_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA MISS
Additional information
- This issue cause every actions on our checkout to take almost 10sec.
- It seems it only happens when use_lua = 1 (which became the default value in 2.4.7)
- Quick workaround = set use_lua = 0 in backend options
Release note
No response
Triage and priority
- [ ] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [X] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @Nuranto. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:
@magento give me 2.4-develop instance- upcoming 2.4.x release- For more details, review the Magento Contributor Assistant documentation.
- Add a comment to assign the issue:
@magento I am working on this - To learn more about issue processing workflow, refer to the Code Contributions.
Join Magento Community Engineering Slack and ask your questions in #github channel. :warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting. :clock10: You can find the schedule on the Magento Community Calendar page. :telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.
Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - [ ] 5. Add label
Issue: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @Nuranto,
Thank you for the report and collaboration!
Tried to reproduce this on 2.4-develop and 2.4.7 instance, in our case it is not reproducible. Steps to reproduce followed are same as in description. But we got the expected result:
CACHE Magento_Framework_GraphQlSchemaStitching_Config_Data MISS [] []
CACHE Magento_Framework_GraphQlSchemaStitching_Config_Data HIT [] []
CACHE Magento_Framework_GraphQlSchemaStitching_Config_Data HIT [] []
CACHE Magento_Framework_GraphQlSchemaStitching_Config_Data HIT [] []
CACHE Magento_Framework_GraphQlSchemaStitching_Config_Data HIT [] []
Please let us know if we are missing anything. Thank you.
Then I guess it is related to the content of the cache. Maybe the size of it, or some special characters or sequence of characters.... Anyway, I have no idea how to create reproductible steps without spending a lot of time into it.
@Nuranto, are there any prerequisites like magento should be configured with redis cache?
Yes indeed, the issue only happens when cache is configured to redis with use_lua set to 1 (or not set at all, since use_lua is set to 1 by default)
@Nuranto, configured magento 2.4.7 instance with redis and ran the script, but we still got the Expected result.
It's probably related to the cache content itself then. But as you can see here, it seems there's multiple issues when use_lua = 1 : https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/181 Maybe we should at least disable this parameter by default.
Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
- [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
- [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
- [ ] 3. Add
Area: XXXXXlabel to the ticket, indicating the functional areas it may be related to. - [ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! - [ ] 5. Add label
Issue: Confirmedonce verification is complete. - [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @Nuranto,
I agree with your point and have also gone through the issue mentioned here https://github.com/magento/magento2/issues/38668#issuecomment-2092716125.
But as we can see while setting up the Redis in Magento 2 the use_lua value is by default set to false. Please have a look at the below screenshot:
Please let us know in case we have missed anything.
Thanks
Alright, in my case there was nothing configured for this field after upgrading. Anyway, I guess this option should be always disabled if not resolved.
I think we can close this issue since the real issue is located on another lib.
Thanks for the feedback @Nuranto.
Can you please let us know from which version you have upgraded your Magento to 2.4.7? This might be an issue related to the upgrade process.
Also please elaborate on the below line:
the real issue is located on another lib.
Thanks
From 2.4.6-p4
the real issue is located on another lib.
The error happen somewhere in this lib : https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/blob/d403f4473e1b3cc616fa59d187e817543b6620c1/Cm/Cache/Backend/Redis.php#L589-L631
Hello @Nuranto,
We have tried to reproduce the issue after upgrading the Magento from 2.4.6-p4 to 2.4.7 and the issue is reproducible for us. We are getting the Actual Result mentioned in the main description.
Please refer to the below screenshot for reference:
Hence confirming the issue.
Thanks
:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-11998 is successfully created for this GitHub issue.
:white_check_mark: Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.
:x: You don't have permission to export this issue.
Hi @Nuranto,
The mentioned issue has been taken care by internal team and delivered in https://github.com/magento/magento2/commit/a52ff98f736aadc9b9fc079ebfcf5a194f51f380. Hence closing the issue now.
Thank you!