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

Skip to content

Conversation

@dvesh3
Copy link
Contributor

@dvesh3 dvesh3 commented Jun 19, 2019

Changes in this pull request

Resolves #4531

Additional info

@dvesh3 dvesh3 added this to the 6.0.1 ("Flanders Red Ale") milestone Jun 19, 2019
@dvesh3 dvesh3 requested a review from brusch June 19, 2019 13:39
@giannello
Copy link

This will prevent concurrency when caching the redirects, but won't fully solve the issue, as the requests will "queue" up and re-fill the cache as soon as the previous lock is released. Given the right conditions (time to warm the cache, and amount of requests per second) won't this smoothen out the database load by spreading it over a longer time span (potentially of making some requests time out)?

Shouldn't we acquire the lock only if it's not already acquired by another request, in which case we should just wait until the lock is release and proceed without re-warming the cache?

@dvesh3
Copy link
Contributor Author

dvesh3 commented Jun 21, 2019

@giannello Thanks for your review! I’ve made changes now to force write cache for redirects as previously it was deferred write at shutdown. And also added an extra check after lock is acquired so subsequent requests will not re-fill the cache.

I’m not sure about proceed without re-warming the cache as it could have some side effects. Let’s wait for @brusch suggestions.

@brusch brusch self-assigned this Jun 25, 2019
@brusch
Copy link
Member

brusch commented Jun 26, 2019

The patch works as long as there's no cache write lock set during the first request that should write the item to the cache. If there's a write lock, the item doesn't get into the cache, so the 2nd (or any of the other requests) will not get the contents out of the cache, so we're in the same situation.

Related to: #4573

Let's wait with this PR until we have an answer to #4573 then we can decide if this is the right approach to solve the issue.

@brusch brusch removed this from the 6.0.1 ("Flanders Red Ale") milestone Jul 3, 2019
@brusch brusch added this to the 6.0.3 ("American Pale Ale") milestone Jul 11, 2019
@brusch brusch merged commit 65811a2 into master Jul 15, 2019
@brusch brusch deleted the lock_redirects_caching branch July 15, 2019 10:02
weisswurstkanone pushed a commit that referenced this pull request Jul 15, 2019
* Avoid redirect cache stampede

* Force write redirects cache and avoid re-warming cache

* [Redirects] if there are no redirects, the cache result isn't used -> unnecessary SQL queries
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.

Caching: high database usage after cache cleanup

4 participants