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

Race condition in CHI::Driver::Role::IsSizeAware #35

Open
bes-internal opened this issue Feb 17, 2023 · 0 comments
Open

Race condition in CHI::Driver::Role::IsSizeAware #35

bes-internal opened this issue Feb 17, 2023 · 0 comments

Comments

@bes-internal
Copy link

1

Race condition in discard_to_size():

setup

$cache = CHI->new(
namespace	=> 'resizeimg',
expires_in	=> '5 d',
max_size	=> int(10.01 * 1024*1024), # M
driver		=> 'File',
depth		=> 3,
);

and die in concurency at line 127, when one process working on clean keys from cache in while { } when second process got keys to clean but got empty list (because the final size is not written to cache store in the first process yet) then enter in else { } and die in eval as affirm (line 129) then at line 138

Assertion (iterator returned undef, cache should be empty) failed!
 at /usr/local/lib64/perl5/5.36/Carp/Assert.pm line 341.
        Carp::Assert::affirm(CODE(0x55e658a67468), "iterator returned undef, cache should be empty") called at /usr/local/lib64/perl5/5.36/CHI/Driver/Role/IsSizeAware.pm line 129
        eval {...} called at /usr/local/lib64/perl5/5.36/CHI/Driver/Role/IsSizeAware.pm line 118
        CHI::Driver::Role::IsSizeAware::discard_to_size(CHI::Driver::File__WITH__CHI::Driver::Role::Universal__AND__CHI::Driver::Role::IsSizeAware=HASH(0x55e658642e58), 8396996) called at /usr/local/lib64/perl5/5.36/CHI/Driver/Role/IsSizeAware.pm line 71
        CHI::Driver::Role::IsSizeAware::__ANON__(CODE(0x55e65892d6e0), CHI::Driver::File__WITH__CHI::Driver::Role::Universal__AND__CHI::Driver::Role::IsSizeAware=HASH(0x55e658642e58), "/var/www/nestormedia/testsite/img/pages/647-s.jpg;f=webp;w=40"..., CHI::CacheObject=ARRAY(0x55e658a66f58)) called at (eval 93) line 1
        CHI::Driver::File__WITH__CHI::Driver::Role::Universal__AND__CHI::Driver::Role::IsSizeAware::__ANON__(CHI::Driver::File__WITH__CHI::Driver::Role::Universal__AND__CHI::Driver::Role::IsSizeAware=HASH(0x55e658642e58), "/var/www/nestormedia/testsite/img/pages/647-s.jpg;f=webp;w=40"..., CHI::CacheObject=ARRAY(0x55e658a66f58)) called at (eval 95) line 2

Need to remove affirm at line 127.

2

I don't think we should ever die outside eval in discard_to_size at line 138

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant