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

Redis preloading fails when exec() returns false #37509

Closed
5 tasks
LeanderFS opened this issue May 17, 2023 · 8 comments · Fixed by #37510
Closed
5 tasks

Redis preloading fails when exec() returns false #37509

LeanderFS opened this issue May 17, 2023 · 8 comments · Fixed by #37510
Assignees
Labels
Area: Framework Component: Cache Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@LeanderFS
Copy link
Contributor

Preconditions and environment

  • Magento 2.x
  • Redis 6.0.10 (Probably every version of Redis)
  • phpredis

Steps to reproduce

  1. Install Magento 2 as normal
  2. Enable Redis in env.php under cache->frontend->default
  3. Make sure to set backend option to Magento\\Framework\\Cache\\Backend\\Redis
  4. Set id_prefix and preload_keys
  5. Run bin/magento cache:clean

This might not reproduce the issue in a lot of the cases because in normal scenarios there would be no issues. This issue arises as an edge-case when \Magento\Framework\Cache\Backend\Redis::load is being called.
$this->preloadedData = array_filter(array_combine($this->preloadKeys, $redis->exec())); expects the second parameter of array_combine to be an array, but $redis->exec() can return false in some cases. Leading to an unexpected exception and inability to run cache:clean or similar commands that preload keys in Redis.

Expected result

I expect the cache:clean command to finish without an error.

Actual result

The following exception is thrown:
array_combine(): Argument #2 ($values) must be of type array, bool given

Additional information

The issue is not immediately apparent, but makes more sense when you look into what the \Cm_Cache_Backend_Redis class is doing, which is the class the Magento Redis adapter extends from. The Cm_Cache_Backend_Redis class pipes the requested method through to Credis_Client, which in turn pipes the request to phpredis. The method signature for exec() in Credis_Client tells us that the return value will always be of the type array, but when checking the implementation in phpredis, exec() can return false. Causing the preloading in Magento to fail.

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”.
@m2-assistant
Copy link

m2-assistant bot commented May 17, 2023

Hi @LeanderFS. 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:


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.

@LeanderFS
Copy link
Contributor Author

@magento I am working on this

@engcom-Bravo engcom-Bravo added the Reported on 2.4.x Indicates original Magento version for the Issue report. label May 17, 2023
LeanderFS added a commit to LeanderFS/magento2 that referenced this issue May 17, 2023
…ay_combine receiving false as second argument
@engcom-Bravo engcom-Bravo added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label May 17, 2023
@engcom-Hotel engcom-Hotel self-assigned this May 18, 2023
@m2-assistant
Copy link

m2-assistant bot commented May 18, 2023

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- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - 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 @LeanderFS,

Thanks for the reporting and collaboration!

Just to confirm, you are mentioning phpredis below:

but when checking the implementation in phpredis, exec() can return false. Causing the preloading in Magento to fail.

Are you talking about this repo https://github.com/phpredis/phpredis?

If yes, then we have gone through with the documentation of phpredis for the exec method and it is mentioned there that it can return false, please refer to the below screenshot for reference:

image

I have taken this screenshot from the below file:

https://github.com/phpredis/phpredis/blob/35a7cc094c6c264aa37738b074c4c54c4ca73b87/docs/Redis.html#L591

Thanks

@engcom-Hotel engcom-Hotel added the Issue: needs update Additional information is require, waiting for response label May 18, 2023
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board May 18, 2023
@LeanderFS
Copy link
Contributor Author

Hi @engcom-Hotel

I can confirm I was talking about the phpredis/phpredis repository. I should've mentioned that in the initial message.

The documentation you've linked is exactly what I mean. The PR linked to this issue fixes the scenario where exec() would return false.

@engcom-Hotel
Copy link
Contributor

Thanks @LeanderFS for the response.

We are confirming this issue by looking into the phpredis documentation.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Cache Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Area: Framework and removed Issue: needs update Additional information is require, waiting for response labels May 19, 2023
@m2-community-project m2-community-project bot added this to Pull Request In Progress in High Priority Backlog May 19, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-8809 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented May 19, 2023

✅ 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.

@m2-community-project m2-community-project bot moved this from Pull Request In Progress to Done in High Priority Backlog Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Cache Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

Successfully merging a pull request may close this issue.

4 participants