Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQl Config (SchemaStiching) does not use LockGuardedCacheLoader (Expensive and large config) #39494

Open
5 tasks
steven-hoffman-jomashop opened this issue Dec 18, 2024 · 3 comments
Assignees
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.8-beta1 Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@steven-hoffman-jomashop

Preconditions and environment

Code on 2.4.8-beta1 shows no use of LockGuardedCacheLoader for GraphQl Config Data.

See GraphQl di.xml
For uses see:

This can lead to a 'stampede' type issue for the expensive schema stitching process. By using the LockGuardedCacheLoader, we can prevent this issue when the cache is flushed.

Other notes:

  • LockGuardedCacheLoader should consider supporting different setting for allow_parallel_generation per usage.
  • Most of the expensive parts of schema stitching can be done with di compile. (And the product/other fields merged in as currently done).

Steps to reproduce

  • Clear cache (Or just remove zc:k:{id}_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA)
  • Make 10x GraphQl requests at once / in quick succession.

Expected result

GraphQl schema stitching is only loaded once. (Or F times where F is some small fraction of N; this would mitigate against one process failing).

Actual result

GraphQl schema stitching is run once per request.

Additional information

You can see this effect by monitoring Redis

# Local test instance
$ redis-cli MONITOR | grep -i _MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA | cut -c -150
1734554861.066657 [0 10.0.2.2:63558] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d"
1734554861.068282 [0 10.0.2.2:63562] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d"
1734554861.082297 [0 10.0.2.2:63566] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d"
1734554861.135661 [0 10.0.2.2:63572] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d"
1734554861.141448 [0 10.0.2.2:63576] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d"
1734554861.799215 [0 10.0.2.2:63580] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d"
1734554862.930618 [0 10.0.2.2:63576] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "t"
1734554862.931542 [0 10.0.2.2:63558] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "t"
1734554862.931873 [0 10.0.2.2:63562] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "t"
1734554862.932389 [0 10.0.2.2:63572] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "t"
1734554862.932648 [0 10.0.2.2:63566] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "t"
1734554862.933038 [0 10.0.2.2:63580] "hget" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "t"
1734554862.955289 [0 10.0.2.2:63576] "hmset" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d" "{\"Query\":{\"name\":\"Query\",\"ty
1734554862.968716 [0 10.0.2.2:63576] "sadd" "zc:ti:ABCD_CONFIG" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554862.968721 [0 10.0.2.2:63576] "sadd" "zc:ti:ABCD_MAGE" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554862.973511 [0 10.0.2.2:63566] "hmset" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d" "{\"Query\":{\"name\":\"Query\",\"ty
1734554862.987830 [0 10.0.2.2:63566] "sadd" "zc:ti:ABCD_CONFIG" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554862.987835 [0 10.0.2.2:63566] "sadd" "zc:ti:ABCD_MAGE" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554862.993475 [0 10.0.2.2:63580] "hmset" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d" "{\"Query\":{\"name\":\"Query\",\"ty
1734554863.007311 [0 10.0.2.2:63580] "sadd" "zc:ti:ABCD_CONFIG" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554863.007315 [0 10.0.2.2:63580] "sadd" "zc:ti:ABCD_MAGE" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554863.011244 [0 10.0.2.2:63572] "hmset" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d" "{\"Query\":{\"name\":\"Query\",\"ty
1734554863.024044 [0 10.0.2.2:63572] "sadd" "zc:ti:ABCD_CONFIG" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554863.024048 [0 10.0.2.2:63572] "sadd" "zc:ti:ABCD_MAGE" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554863.024270 [0 10.0.2.2:63562] "hmset" "zc:k:ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA" "d" "{\"Query\":{\"name\":\"Query\",\"ty
1734554863.036918 [0 10.0.2.2:63562] "sadd" "zc:ti:ABCD_CONFIG" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"
1734554863.036922 [0 10.0.2.2:63562] "sadd" "zc:ti:ABCD_MAGE" "ABCD_MAGENTO_FRAMEWORK_GRAPHQLSCHEMASTITCHING_CONFIG_DATA"

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • 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”.
Copy link

m2-assistant bot commented Dec 18, 2024

Hi @steven-hoffman-jomashop. 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.


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 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.

@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Dec 18, 2024
@engcom-Bravo engcom-Bravo added Reported on 2.4.8-beta1 Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it labels Dec 19, 2024
@engcom-Hotel engcom-Hotel self-assigned this Dec 30, 2024
Copy link

m2-assistant bot commented Dec 30, 2024

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: 👇

  • 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: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced 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: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @steven-hoffman-jomashop,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the latest development branch i.e. 2.4-develop by adding logger in the below class:

public function read($scope = null) : array
{
$output = [];
foreach ($this->readers as $reader) {
$output = array_replace_recursive($output, $reader->read($scope));
}
return $output;
}

We used the below script to send the multiple GraphQL requests:

Curl-PHP Script $multiCurl = [];
$responses = [];
$mh = curl_multi_init();
for ($i = 0; $i < $totalRequests; $i++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'BASE_URL/graphql');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept-Encoding: gzip, deflate, br',
'Content-Type: application/json',
'Accept: application/json',
'Connection: keep-alive',
'Origin: chrome-extension://flnheeellpciglgpaodhkhmapeljopja',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"query":"{\n products(search: \"Simple 1\", pageSize: 2) {\n total_count\n items {\n name\n sku\n price_range {\n minimum_price {\n regular_price {\n value\n currency\n }\n }\n }\n }\n page_info {\n page_size\n current_page\n }\n }\n}","variables":{}}');

curl_multi_add_handle($mh, $ch);
$multiCurl[$i] = $ch;

}

do {
$status = curl_multi_exec($mh, $active);
if ($active) {
curl_multi_select($mh);
}
} while ($active && $status == CURLM_OK);

foreach ($multiCurl as $i => $ch) {
$responses[$i] = curl_multi_getcontent($ch); // Get the response
curl_multi_remove_handle($mh, $ch); // Remove the handle
curl_close($ch); // Close the handle
}
curl_multi_close($mh);
foreach ($responses as $response) {
print_r($response);
}

As per the script we have sent 100 simultaneous requests and it logs 40 times in the logger file. Are you talking about the same behaviour or please tell us if we have missed anything.

Thanks

@engcom-Hotel engcom-Hotel added Issue: needs update Additional information is require, waiting for response and removed Issue: ready for confirmation labels Dec 30, 2024
@engcom-Hotel engcom-Hotel moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: needs update Additional information is require, waiting for response Reported on 2.4.8-beta1 Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

No branches or pull requests

3 participants