Skip to content

[Lock] prune PdoStorage table on each save according to gcProbability #31804

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

Closed
wants to merge 2 commits into from
Closed

Conversation

pableu
Copy link
Contributor

@pableu pableu commented Jun 3, 2019

Q A
Branch? 4.2
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
License MIT

I expected the \Symfony\Component\Lock\Store\PdoStore::prune method to be called according to gcProbability every time I interact with a lock. But \Symfony\Component\Lock\Store\PdoStore::save returns early on success. As I see it, this means that expired locks are pruned much less often than specified by gcProbability.

This PR fixes that by calling prune before the early return.

I'm not so sure if checking the probability inside the prune method is a good solution. Maybe it would be nicer to have a separate function (randomPrune).

@nicolas-grekas nicolas-grekas changed the base branch from master to 4.2 June 3, 2019 19:06
@nicolas-grekas nicolas-grekas changed the base branch from 4.2 to master June 3, 2019 19:06
@nicolas-grekas nicolas-grekas added this to the 4.2 milestone Jun 3, 2019
@nicolas-grekas
Copy link
Member

What about moving the "if" in a "finally" block? (an not put it inside the method I agree)
please rebase+retarget for 4.2 also.

@nicolas-grekas
Copy link
Member

Closing in favor of #32076, thank you!

@pableu
Copy link
Contributor Author

pableu commented Jun 18, 2019

Okay perfect. Sorry I haven't had time to work on this, but #32076 looks great.

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.

3 participants