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

Merged
nicolas-grekas merged 0 commit intosymfony:4.4from
phamviet:PR-38635
Oct 29, 2020
Merged

[Cache] Fixed expiry could be int in ChainAdapter due to race conditions#38879
nicolas-grekas merged 0 commit intosymfony:4.4from
phamviet:PR-38635

Conversation

@phamviet
Copy link
Copy Markdown
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
Copy Markdown
Member

Thank you @phamviet.

@nicolas-grekas
Copy link
Copy Markdown
Member

For ref, I improved this a bit in 13af58c

@Nyholm
Copy link
Copy Markdown
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