rhubarbgroup / .github

Community Health Files
https://github.com/rhubarbgroup/
0 stars 0 forks source link

Purging Cache Results in Error #17

Closed jordantrizz closed 1 year ago

jordantrizz commented 1 year ago

Description

When running the "Purge Cache" operation, an error will occur.

Expected Behavior

There should be no error if Redis is unavailable during a purge of cache.

Actual Behavior

The temporarily unavailable exceptions should be handled gracefully.

Possible Fix

Change the exception to soft fail and report to error_log()

Steps to Reproduce

  1. Setup redis-cache plugin.
  2. Setup a WooCommerce store
  3. Fill up the Redis cache
  4. Purge the Redis cache.

Additional context

This occurs with phpredis or relay.

WordPress debug log

[08-Jun-2023 13:22:11 UTC] Relay\Exception: Resource temporarily unavailable (RELAY_ERR_IO; relay.c:1055) in /var/www/domain.com/htdocs/wp-content/object-cache.php:563
Stack trace:
#0 /var/www/domain.com/htdocs/wp-content/object-cache.php(563): Relay\Relay->ping()
rhubarbgroup/redis-cache#1 /var/www/domain.com/htdocs/wp-content/object-cache.php(256): WP_Object_Cache->__construct()
rhubarbgroup/redis-cache#2 /var/www/domain.com/htdocs/wp-includes/load.php(750): wp_cache_init()
rhubarbgroup/redis-cache#3 /var/www/domain.com/htdocs/wp-settings.php(131): wp_start_object_cache()
rhubarbgroup/redis-cache#4 /var/www/domain.com/wp-config.php(109): require_once('/var/www/americ...')
rhubarbgroup/redis-cache#5 /var/www/domain.com/htdocs/wp-load.php(55): require_once('/var/www/americ...')
rhubarbgroup/redis-cache#6 /var/www/domain.com/htdocs/wp-login.php(12): require('/var/www/americ...')
rhubarbgroup/redis-cache#7 {main}

Next Relay\Exception: Resource temporarily unavailable (RELAY_ERR_IO; cache.c:1091) in /var/www/domain.com/htdocs/wp-content/object-cache.php:563
Stack trace:
#0 /var/www/domain.com/htdocs/wp-content/object-cache.php(563): Relay\Relay->ping()
rhubarbgroup/redis-cache#1 /var/www/domain.com/htdocs/wp-content/object-cache.php(256): WP_Object_Cache->__construct()
rhubarbgroup/redis-cache#2 /var/www/domain.com/htdocs/wp-includes/load.php(750): wp_cache_init()
rhubarbgroup/redis-cache#3 /var/www/domain.com/htdocs/wp-settings.php(131): wp_start_object_cache()
rhubarbgroup/redis-cache#4 /var/www/domain.com/wp-config.php(109): require_once('/var/www/americ...')
rhubarbgroup/redis-cache#5 /var/www/domain.com/htdocs/wp-load.php(55): require_once('/var/www/americ...')
rhubarbgroup/redis-cache#6 /var/www/domain.com/htdocs/wp-login.php(12): require('/var/www/americ...')
rhubarbgroup/redis-cache#7 {main}

redis-server.log

1086:M 08 Jun 2023 09:22:14.540 # Lua slow script detected: still in execution after 5029 milliseconds. You can try killing the script using the SCRIPT KILL command. Script SHA1 is: 86aed9cfd0f64a9346ab38c233d747c4a871f64f
1086:M 08 Jun 2023 09:22:31.526 * 10000 changes in 60 seconds. Saving...
1086:M 08 Jun 2023 09:22:31.578 * Background saving started by pid 2956645
2956645:C 08 Jun 2023 09:22:33.984 * DB saved on disk
2956645:C 08 Jun 2023 09:22:34.032 * RDB: 65 MB of memory used by copy-on-write
1086:M 08 Jun 2023 09:22:34.149 * Background saving terminated with success
1086:M 08 Jun 2023 09:22:34.251 * Starting automatic rewriting of AOF on 108% growth
1086:M 08 Jun 2023 09:22:34.302 * Background append only file rewriting started by pid 2956679
1086:M 08 Jun 2023 09:22:36.875 * AOF rewrite child asks to stop sending diffs.
2956679:C 08 Jun 2023 09:22:36.875 * Parent agreed to stop sending diffs. Finalizing AOF...
2956679:C 08 Jun 2023 09:22:36.875 * Concatenating 2.45 MB of AOF diff received from parent.
2956679:C 08 Jun 2023 09:22:36.880 * SYNC append only file rewrite performed
2956679:C 08 Jun 2023 09:22:36.923 * AOF rewrite: 46 MB of memory used by copy-on-write
1086:M 08 Jun 2023 09:22:37.003 * Background AOF rewrite terminated with success
1086:M 08 Jun 2023 09:22:37.003 * Residual parent diff successfully flushed to the rewritten AOF (0.02 MB)
1086:M 08 Jun 2023 09:22:37.003 * Background AOF rewrite finished successfully

Environment

tillkruss commented 1 year ago
Lua slow script detected: still in execution after 5029 milliseconds. 

Are you using "selective flushing"?

jordantrizz commented 1 year ago

No, simply using the admin bar method.

tillkruss commented 1 year ago

@jordantrizz: What do you see under Settings > Redis?

jordantrizz commented 1 year ago

Here you go!

Status:  Connected
Filesystem:  Writeable
Redis:   Reachable
Key Prefix: eip2H_object_cache_domain.com
Connection
Client: Relay (v0.6.4)
Host:   127.0.0.1
Port:   6379
Database:   0
Connection Timeout: 1s
Read Timeout:   1s
Retry Interval: 0ms
Redis Version:  6.0.6
tillkruss commented 1 year ago

We need the full diagnostics dump.

jordantrizz commented 1 year ago

Of course, sorry about that.

Status: Connected
Client: Relay (v0.6.4)
Drop-in: Valid
Disabled: No
Ping: 1
Errors: []
PhpRedis: 5.3.7
Relay: 0.6.4
Predis: 2.1.2
Credis: Not loaded
PHP Version: 7.4.33
Plugin Version: 2.4.1
Redis Version: 6.0.6
Multisite: No
Metrics: Enabled
Metrics recorded: 728
Filesystem: Working
Global Prefix: "wp_"
Blog Prefix: "wp_"
WP_REDIS_CLIENT: "relay"
WP_REDIS_SCHEME: "unix"
WP_REDIS_PATH: "/var/run/redis/redis-server.sock"
WP_REDIS_PREFIX: "eip2H_object_cache_domain.com"
WP_CACHE_KEY_SALT: "eip2H_object_cache_domain.com"
WP_REDIS_PLUGIN_PATH: "/var/www/domain.com/htdocs/wp-content/plugins/redis-cache"
WP_REDIS_SELECTIVE_FLUSH: true
Global Groups: [
    "blog-details",
    "blog-id-cache",
    "blog-lookup",
    "global-posts",
    "networks",
    "rss",
    "sites",
    "site-details",
    "site-lookup",
    "site-options",
    "site-transient",
    "users",
    "useremail",
    "userlogins",
    "usermeta",
    "user_meta",
    "userslugs",
    "redis-cache",
    "blog_meta"
]
Ignored Groups: [
    "counts",
    "plugins",
    "themes",
    "theme_json"
]
Unflushable Groups: []
Groups Types: {
    "blog-details": "global",
    "blog-id-cache": "global",
    "blog-lookup": "global",
    "global-posts": "global",
    "networks": "global",
    "rss": "global",
    "sites": "global",
    "site-details": "global",
    "site-lookup": "global",
    "site-options": "global",
    "site-transient": "global",
    "users": "global",
    "useremail": "global",
    "userlogins": "global",
    "usermeta": "global",
    "user_meta": "global",
    "userslugs": "global",
    "redis-cache": "global",
    "counts": "ignored",
    "plugins": "ignored",
    "themes": "ignored",
    "blog_meta": "global",
    "theme_json": "ignored"
}
Drop-ins: [
    "advanced-cache.php v by ",
    "Redis Object Cache Drop-In v2.4.1 by Till Krüss"
]