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

Gracefully fail when Redis commands fail #461

Open
danielvonmitschke opened this issue Apr 26, 2023 · 5 comments
Open

Gracefully fail when Redis commands fail #461

danielvonmitschke opened this issue Apr 26, 2023 · 5 comments

Comments

@danielvonmitschke
Copy link

danielvonmitschke commented Apr 26, 2023

Hi,

I am using redis-cache on a plesk server with a bitnami/redis docker container.

In my log file I get quite a few fatal errors in the form of Uncaught RedisException: read error on connection to 127.0.0.1:6379 in /var/www/vhosts/sites/www.web/app/object-cache.php:1897.

In your FAQ your write to just ignore there error and that would be total fine with me.

Unfortunately there is a "BUT":
I saw quite a few instances where this caused some basic wordpress or woocommerce "operations" to fail.
And in my opinion that should not be the case.

Here is what I mean with that:
We have some operation in wordpress or woocommerce that is trying to "do" something and in some place it uses caching or transients. Most of the time that would be just asking if there is some value in the cache and if not to do a costly calculation of this value.
But if there is a connection problem with redis this causes the whole operation to break.
Instead redis-cache should fail gracefully in this case and just behave as if the value wasn't present in the cache (e.g. return false or whatever the default value is for that).
This of course should be applied to all redis cache functions.
This way we wouldn't break any higher level operations just because the cache is not working for a split second.

Please let me know what you think.

Best,

daniel

@tillkruss
Copy link
Member

@danielvonmitschke: That's exactly what Object Cache Pro does. However this plugin would need quite a bit of work done to accomplish that. We're always open to a pull request if you like to contribute this.

@tillkruss tillkruss changed the title About fatal erros Gracefully fail when Redis commands fail Apr 26, 2023
@danielvonmitschke
Copy link
Author

Thank you. Unfortunately the pro version is out of our price range.
Actually never realized that the pro version is a plugin. It seemed more like an external caching service (though I wouldn't know how this would work non-local). at least the monthly fee suggested that this is not only a plugin.

@tillkruss
Copy link
Member

Yeah, it's certainly a high end product. It looks like non of the FOSS plugins do graceful return values.

@waqasy
Copy link

waqasy commented Sep 29, 2023

My mind boggles to see that this plugin has option "WP_REDIS_GRACEFUL" parameter to bypass 500 error when redis not available, yet developer hasn't added this option in plugin settings by default. Why the sites of naive users should appear broken and face alot of panic when 500 error appear for visitors (which may last for hours when go unnoticed)

What OP has asked is very basic behavior of any reasonable caching plugin offers. Actually this is the prime feature of every cache solution. to use fallback if cache not available or service unavailable.

@tillkruss
Copy link
Member

What an ignorant comment...

When the mind is boggled, it's wise to ask questions. For example:

  • Why is WP_REDIS_GRACEFUL not enabled by default?
  • Is there a downside to using WP_REDIS_GRACEFUL?

You get excellent answers like:

  • WP_REDIS_GRACEFUL is not enabled by default, because the typical WordPress user does NOT monitor Redis, so they don't know whether Redis Server is available and object caching is working.
  • Using WP_REDIS_GRACEFUL is very risky, because if requests happen without the cache being updated (for example a checkout, or post is updated) then the SQL database will contain different information that what cache will return once the Redis Server is back online. This has lead to horrible dataloss (if you search the wp.org) forums.

Furthermore, if you'd like a better WP_REDIS_GRACEFUL support, this is free and open source software and you could open a Pull Request. Even if you can't code, you could extend the documentation and installation instruction instead of whining...

@rhubarbgroup rhubarbgroup locked as too heated and limited conversation to collaborators Sep 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants