Skip to content

Fix usage of EAV cache type #31264

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

Merged

Conversation

ilnytskyi
Copy link
Contributor

@ilnytskyi ilnytskyi commented Dec 11, 2020

Description (*)

This PR fixes usage of EAV cache type in some places

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Different frontend type can be set to EAV cache type without defining additional eav frontend type introduced by configured_eav_cache virtual type
    UPD: looks like it's bigger problem I see many other classes do not use \Magento\Eav\Model\Cache\Type and they can't be fixed due to Magento\Framework\App\CacheInterface and Magento\Framework\Cache\FrontendInterface incompatibilities.
    It should be figured out and fixed in different PR/issue.
  2. Class \Magento\Catalog\Plugin\Model\ResourceModel\Config checks if EAV cache enabled but store data in default cache type. This PR fixes missed configuration

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Fix usage of EAV cache type #32322: Fix usage of EAV cache type

@m2-assistant
Copy link

m2-assistant bot commented Dec 11, 2020

Hi @ilnytskyi. Thank you for your contribution
Here is some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests 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 Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@ilnytskyi
Copy link
Contributor Author

@magento run all tests

Copy link
Contributor

@lbajsarowicz lbajsarowicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 I don't see any critical issues there.
Let's wait for Static Tests to finish, but the only issue is code style to adjust.

@lbajsarowicz
Copy link
Contributor

@magento run all tests

@ilnytskyi
Copy link
Contributor Author

I think that in
\Magento\Catalog\Plugin\Model\ResourceModel\Config
Wrong cache interface used or something
will try to figure out how to fix it.

@ilnytskyi ilnytskyi force-pushed the fix-eav-cache-type branch 2 times, most recently from 5f17403 to fc04ddb Compare December 12, 2020 08:25
@ilnytskyi
Copy link
Contributor Author

@magento run all tests

@ilnytskyi
Copy link
Contributor Author

ilnytskyi commented Dec 12, 2020

I decided to open PR after I saw this change. But now i see it's a bit bigger problem.

4b66b00#diff-b3fae67f1de2de925eb945c0dac8213f1f6f817053039c4d15eb698a338a3ac3

@vzabaznov could you take a look at this issue and help us figure out what to do?

I our project we use different cache backends for different cache types. Mainly to reduce data transfer from redis, and isolate containers in ASG and with 2.4.1 magento we faced the issue, that in RemoteSynchronized cache not all EAV keys were stored in containers. The first issue was the necessity to use a separate frontend with the name eav. And the other issue that, some classes still did not use proper cache types to store the date, e.g. Magento\Catalog\Plugin\Model\ResourceModel\Config

Probably the issue was not noticed since devs don't usually use this approach to point some caches to different storages, or do not debug if the keys actually come from proper storage.

This is serious issue because these docs pages do not really represent what actually going inside the app.
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/cache/partial-caching/database-caching.html and
https://devdocs.magento.com/guides/v2.4/extension-dev-guide/cache/partial-caching/database-caching.html#mage-cache-db-env

@ilnytskyi
Copy link
Contributor Author

@maghamed could you explain some differences between
Magento\Framework\Cache\FrontendInterface and Magento\Framework\App\CacheInterface and why configured_eav_cache virtual type used for EAV cache instead of Magento\Eav\Model\Cache\Type ?

As a dev I do not see point to define EAV cache type in XML https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Eav/etc/cache.xml and then use different classes that implement different interfaces to actually work with the cache storage.

@gabrieldagama gabrieldagama added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. labels Dec 15, 2020
@engcom-Hotel engcom-Hotel self-assigned this Dec 23, 2020
@engcom-Hotel
Copy link
Contributor

@magento run WebAPI Tests

1 similar comment
@engcom-Hotel
Copy link
Contributor

@magento run WebAPI Tests

@lbajsarowicz
Copy link
Contributor

Sorry, @engcom-Hotel - I'm no longer Maintainer.
@ihor-sviziev might be able to help

@ilnytskyi
Copy link
Contributor Author

@engcom-Dash

Class \Magento\Catalog\Plugin\Model\ResourceModel\Config checks if EAV cache enabled but store data in default cache type. This PR fixes missed configuration

basically the class checks if EAV cache enabled
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Plugin/Model/ResourceModel/Config.php#L52

but actual read write happend on default cache type, not eav
https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Catalog/Plugin/Model/ResourceModel/Config.php#L73

can be checked via actual type of passed CacheInterface $cache,

@engcom-Dash
Copy link
Contributor

@magento run all tests

@engcom-Dash
Copy link
Contributor

@ilnytskyi - I have configured the L2 cache and checked the type of CacheInterface $cache, but I didn't notice any changes after implementing PR changes. Could you please let me know if I’m missing anything? Thanks.

Please see the Xdebug response for CacheInterface $cache below:
image

@ilnytskyi
Copy link
Contributor Author

@engcom-Dash If you configure EAV to be stored in different storage than default.

Let's say default is Redis, and EAV is filesystem.

Maybe follow instruction from this docs - https://experienceleague.adobe.com/en/docs/commerce-operations/configuration-guide/cache/redis/redis-pg-cache#results
As one can see different backends can be configured per cache type.

Default cache is always

'backend' => '\\Magento\\Framework\\Cache\\Backend\\Redis',

and EAV

'backend' => 'Cm_Cache_Backend_File'

Are data actually writtend to the Redis or Filesystem for those keys?
Expected destination would be EAV to filesystem not to redis.

We found this issue when trying avoid using L2 but just store EAV type in tmpfs on the server. But we noticed that EAV in those kays still used default destination.

@engcom-Dash
Copy link
Contributor

Hello @ilnytskyi ,

Thanks for the contributions!

I configured different storage location for EAV and noticed that it was still being stored in the default destination. After implementing the PR changes, it now stores in the configured location as expected. Although I was unable to check the type of cacheIdentifier using Xdebug, but since this PR fixes the misconfiguration, I’m moving it to Extended Testing(as the builds are currently failing).

Thanks!

@engcom-Dash
Copy link
Contributor

@magento run all tests

@lbajsarowicz lbajsarowicz removed their assignment Nov 12, 2024
@engcom-Dash
Copy link
Contributor

@magento run all tests

@hostep hostep removed their assignment Nov 12, 2024
@engcom-Dash engcom-Dash self-assigned this Nov 12, 2024
@engcom-Dash
Copy link
Contributor

@magento run Functional Tests B2B

@engcom-Dash
Copy link
Contributor

engcom-Dash commented Nov 13, 2024

@magento-devops-reposync-svc magento-devops-reposync-svc merged commit 830a2ad into magento:2.4-develop Dec 4, 2024
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Component: Eav Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: accept Project: Community Picked PRs upvoted by the community Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Fix usage of EAV cache type