Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Cache] Fixed expiry could be int in ChainAdapter due to race conditions #38879

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
merged 0 commits into from
Oct 29, 2020

Conversation

phamviet
Copy link
Contributor

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #38635
License MIT
Doc PR no

This bug is hard to re-produce and seems only happen with ArrayAdapter only.

Steps to reproduce:

cache.yaml

simple.cache:
        adapters:
          - cache.adapter.array
          - cache.adapter.redis
if (isset($item->metadata[CacheItem::METADATA_EXPIRY])) {
    $logger->debug($item->key, $item->metadata);
    $format = is_int($item->metadata[CacheItem::METADATA_EXPIRY]) ? 'U' : 'U.u';
    $item->expiresAt(\DateTime::createFromFormat($format, $item->metadata[CacheItem::METADATA_EXPIRY]));
 }

Refresh webpage multiple time to make web server busy and logs:

[2020-10-29T17:04:51.119653+07:00] application.DEBUG: item-key {"expiry":1603965892.118222,"ctime":4} []
[2020-10-29T17:04:54.322937+07:00] application.DEBUG: item-key {"expiry":1603965895.308393,"ctime":17} []
[2020-10-29T17:04:54.745923+07:00] application.DEBUG: item-key {"expiry":1603965895,"ctime":16} []

@nicolas-grekas
Copy link
Member

Thank you @phamviet.

@nicolas-grekas
Copy link
Member

For ref, I improved this a bit in 13af58c

@Nyholm
Copy link
Member

Nyholm commented Oct 29, 2020

Thank you @phamviet for finding and fixing this!

@fabpot fabpot mentioned this pull request Nov 10, 2020
This was referenced Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants