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

object-cache.php uses flushAll, not flushDb #258

Closed
wetcoast opened this issue Dec 18, 2019 · 2 comments · Fixed by #259
Closed

object-cache.php uses flushAll, not flushDb #258

wetcoast opened this issue Dec 18, 2019 · 2 comments · Fixed by #259
Milestone

Comments

@wetcoast
Copy link

The use of flushAll in object-cache.php is catastrophic if you are using multiple databases in Redis. Not sure why flushdb isn't used here instead since database partitioning is built in.

We have 14 separate databases in our Redis implementation with different apps/services using different dBs. Couldn't explain why dBs were seemingly randomly losing all cached data until we eventually tracked it down to the use of wp-redis's object-cache.php in our WordPress projects, each of which is using a separate dB in a single Redis deployment.

@danielbachhuber
Copy link
Contributor

Hey @wetcoast,

Thanks for the report!

The use of flushAll in object-cache.php is catastrophic if you are using multiple databases in Redis.

Yep, definitely.

Not sure why flushdb isn't used here instead since database partitioning is built in.

Do you know if database partitioning has always been built into Redis, or is it a more recent thing?. Seems like it's been around since 1.0.0

It looks like the flushAll call landed in the mega initial commit, so I'm not sure there's much we can derive from history:

c848657#diff-5a2b681f0d32956de83215ea32388177R420-R423

However, another popular Redis object cache uses flushdb(), so it's probably fine to switch to: https://github.com/tillkruss/redis-cache/blob/master/includes/object-cache.php#L821

Our tests pass with it too #259

We have 14 separate databases in our Redis implementation with different apps/services using different dBs. Couldn't explain why dBs were seemingly randomly losing all cached data until we eventually tracked it down to the use of wp-redis's object-cache.php in our WordPress projects, each of which is using a separate dB in a single Redis deployment.

Sorry about that :( Must've been a painful bug.


I'm hesitant to tag a new release right now. You're welcome to apply the change however most convenient if you want an immediate fix, and I'll tag WP Redis v0.8.0 with the change on the first full week of January.

@danielbachhuber
Copy link
Contributor

@wetcoast This is now released in v0.8.0. Thanks again for the report.

@danielbachhuber danielbachhuber added this to the 0.8.0 milestone Jan 6, 2020
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

Successfully merging a pull request may close this issue.

2 participants