-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
L2 cache save operation stop working when the hash key exists on remo… #36418
base: 2.4-develop
Are you sure you want to change the base?
L2 cache save operation stop working when the hash key exists on remo… #36418
Conversation
Hi @georgebabarus. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review. For more details, review the Magento Contributor Guide documentation. 🕙 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, join the Community Contributions Triage session to discuss the appropriate ticket. ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
89a7ffc
to
9a458ed
Compare
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
1 similar comment
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run WebAPI Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Integration Tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests CE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@magento run Functional Tests EE |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time. |
@georgebabarus could this also cause the user (customer) that was on the checkout or somewhere else could be logged out by force because of this? |
@leonhelmus This proposal is strictly related to cache storage. Not related to customer session issues. |
…te server but the data key was evicted meanwhile Later edit: this is a refactor solution after the solution was already provided for the original issue
9a458ed
to
8882562
Compare
@magento run tests |
Failed to run the builds. Please try to re-run them later. |
@magento run all tests |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run Functional Tests B2B |
The requested builds are added to the queue. You should be able to see them here within a few minutes. Please message the #magento-devops slack channel if they don't show in a reasonable amount of time and a representative will look into any issues. |
@magento run Sample Data Tests B2B |
Failed to run the builds. Please try to re-run them later. |
@magento run Sample Data Tests CE |
Failed to run the builds. Please try to re-run them later. |
@magento run Sample Data Tests EE |
Failed to run the builds. Please try to re-run them later. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!$isRemoteUpToDate) { | ||
$this->remote->save($data, $id, $tags, $specificLifetime); | ||
$this->saveRemoteDataVersion($data, $id, $tags, $specificLifetime); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @georgebabarus,
Can you please let us know the reason behind removing this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is not useful: if the version is correct and the data is correct -> the save method is not called, because this is a cache hit by definition.
The purpose of the cache is to avoid generating the data, all the consistency check should be done in the load method which is preventing the data to be generated.
Once the data is generated I think is better to save it since the heavy processing was already done before the save action:
- consistency check with Remote storage, done in the load method -> this should say what a cache hit means
- data generated
Save operation stop working on L2 cache and remote cache when the hash key exists on remote server, but the data key was evicted meanwhile from remote cache.
Later edit: The original issue has been fixed int magento:2.4-develop branch, but this is a performance improvement implementation that should be beneficial by following argument: The concept of cache involves try loading the data from storage, generate if data doesn't exist in cache, and save it to cache. There is no need to check if data exist in cache in the save method.
Description (*)
When save method is called on L2 cache adapter there are 3 things do be done:
The original checks of the remote version of data are preventing the save of the cache to remote and local servers in the scenario where the version id exists and is correct but the data is missing from remote server. (eg: because it was evicted by Redis)
In order to avoid unnecessary writes on the remote server for both entries from point 1 and 2, it needs to read both keys content and TTL in order to create a condition that will cover all the cases. I find this solution overkill and I think it make more sense to force write both keys on remote server. The cache lock is a different component that could perform the above purpose of reducing the writes.
Important note: the remote cache consistency check should be performed in the load method
Follow the red arrows to see the failing scenario:
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)