Support » Plugin: Redis Object Cache » Status: Not Connected despite plugin can see Redis server

  • Resolved CodeBard

    (@codebard)


    Kubernetes, using a custom docker image with debian buster PHP 7.3 fpm, Apache. Connecting to an in-cluster Redis cluster directly. No matter which version of php-redis i install (4.2.0 Debian Buster default, or, 5.2.2 latest or 5.1.0 version from PECL) i still get status Not Connected. The plugin can see the Redis server and ping it however, also can get its info. Using a sidecar im able to connect to the server and query it easily with redis-cli. The Redis cluster requires -c flag (allowing redirection of queries?) maybe that is the reason?

    Configuration is below:

    define( 'WP_REDIS_HOST', 'redis-cluster' );
    define( 'WP_CACHE', true );
    // define( 'WP_REDIS_CLIENT', 'pecl' );
    define( 'WP_REDIS_PASSWORD', 'SOMEPASSWORD' );
    define( 'WP_REDIS_DATABASE', '0' );
    define( 'WP_CACHE_KEY_SALT', 'SOMESALTHERE' );
    define( 'WP_REDIS_SELECTIVE_FLUSH', true );
    define( 'WP_REDIS_DISABLE_BANNERS', true );

    Diagnostics in plugin:

    Status: Not Connected
    Client: PhpRedis (v5.1.0)
    Drop-in: Valid
    Ping: 1
    Redis Extension: 5.1.0
    Predis Client: 1.1.1
    PHP Version: 7.3.14-1~deb10u1
    Redis Version: 5.0.9
    Multisite: Yes
    Global Prefix: ""
    Blog Prefix: 1
    WP_REDIS_HOST: "redis-cluster"
    WP_REDIS_DATABASE: "0"
    WP_CACHE_KEY_SALT: "SOMESALTHERE"
    WP_REDIS_PASSWORD: "**********"
    Global Groups: {
        "0": "blog-details",
        "1": "blog-id-cache",
        "2": "blog-lookup",
        "3": "global-posts",
        "4": "networks",
        "5": "rss",
        "6": "sites",
        "7": "site-details",
        "8": "site-lookup",
        "9": "site-options",
        "10": "site-transient",
        "11": "users",
        "12": "useremail",
        "13": "userlogins",
        "14": "usermeta",
        "15": "user_meta",
        "16": "userslugs",
        "33": "blog_meta"
    }
    Ignored Groups: [
        "counts",
        "plugins",
        "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",
        "blog_meta",
        "themes"
    ]
    Unflushable Groups: []
Viewing 15 replies - 1 through 15 (of 18 total)
  • Plugin Author Till Krüss

    (@tillkruess)

    Hi @codebard. It’s unlikely Predis or PhpRedis, it sound like a permissions thing.

    Try placing file in your WP root and access it via HTTP, that might reveal the exception.

    
    <?php
    
    $redis = new Redis;
    $redis->connect('redis-cluster', 6379);
    
    var_dump($redis);
    

    thanks Till – with that file…

    object(Redis)#1 (0) { }

    …is the output.

    Plugin Author Till Krüss

    (@tillkruess)

    Try adding this line:

    
    var_dump($redis->ping('test'));
    

    The later bit of code prints out absolutely nothing. Not even an empty array.

    Plugin Author Till Krüss

    (@tillkruess)

    It must show at least null, if it doesn’t show anything, then there must be an error in your logs.

    Im wondering if this has anything to do with Bitnami’s Redis cluster for Kubernetes.

    Plugin Author Till Krüss

    (@tillkruess)

    If redis-cli works then there must be some issue with PHP-FPM connecting to Redis. I’ve seen Kubernetes/Docker setups in the past and most of the time is’s a networking issues between “web” and “redis” containers.

    The thing is that the plugin seems to be able to see the redis server and ping it, right? It returns 1. And when i was using another version of Redis client (phpredis) it was ponging to ‘ping’. So connectivity should be there? Or is there any other particular pitfall that mmay be aside from connectivity?

    Plugin Author Till Krüss

    (@tillkruess)

    Maybe this is a bug in the status display.

    Can you try flushing your Redis database, then load a WP page, then see how many keys are in Redis?

    Below INFO stat outputs show the stats before and after db was flushed with FLUSHALL

    redis-cluster:6379> INFO stats
    # Stats
    total_connections_received:33500
    total_commands_processed:150132
    instantaneous_ops_per_sec:2
    total_net_input_bytes:4729375
    total_net_output_bytes:2340663
    instantaneous_input_kbps:0.07
    instantaneous_output_kbps:0.01
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:1
    expired_keys:0
    expired_stale_perc:0.00
    expired_time_cap_reached_count:0
    evicted_keys:0
    keyspace_hits:238
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:1043
    migrate_cached_sockets:0
    slave_expires_tracked_keys:0
    active_defrag_hits:0
    active_defrag_misses:0
    active_defrag_key_hits:0
    active_defrag_key_misses:0
    
    redis-cluster:6379> INFO stats
    # Stats
    total_connections_received:33506
    total_commands_processed:150159
    instantaneous_ops_per_sec:1
    total_net_input_bytes:4730216
    total_net_output_bytes:2341410
    instantaneous_input_kbps:0.05
    instantaneous_output_kbps:0.01
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:1
    expired_keys:0
    expired_stale_perc:0.00
    expired_time_cap_reached_count:0
    evicted_keys:0
    keyspace_hits:238
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:1043
    migrate_cached_sockets:0
    slave_expires_tracked_keys:0
    active_defrag_hits:0
    active_defrag_misses:0
    active_defrag_key_hits:0
    active_defrag_key_misses:0
    

    Currently DBSIZE outputs 0.

    I refreshed the site’s pages and visited some other urls in order to effect a cache read/write after flushing the db.

    Plugin Author Till Krüss

    (@tillkruess)

    Are you using a real cluster? If so you’ll need to use a different constant and not WP_REDIS_HOST.

    Can you post the full INFO command?

    redis-cluster:6379> INFO
    # Server
    redis_version:5.0.9
    redis_git_sha1:00000000
    redis_git_dirty:0
    redis_build_id:19c09cb14abb2b16
    redis_mode:cluster
    os:Linux 4.19.0-0.bpo.6-amd64 x86_64
    arch_bits:64
    multiplexing_api:epoll
    atomicvar_api:atomic-builtin
    gcc_version:8.3.0
    process_id:1
    run_id:fac89c6f3024d0b95953da813edead2fe2a3e1d7
    tcp_port:6379
    uptime_in_seconds:84263
    uptime_in_days:0
    hz:10
    configured_hz:10
    lru_clock:12175140
    executable:/opt/bitnami/redis/bin/redis-server
    config_file:
    
    # Clients
    connected_clients:1
    client_recent_max_input_buffer:2
    client_recent_max_output_buffer:0
    blocked_clients:0
    
    # Memory
    used_memory:2658648
    used_memory_human:2.54M
    used_memory_rss:12488704
    used_memory_rss_human:11.91M
    used_memory_peak:3465568
    used_memory_peak_human:3.31M
    used_memory_peak_perc:76.72%
    used_memory_overhead:2578594
    used_memory_startup:1463320
    used_memory_dataset:80054
    used_memory_dataset_perc:6.70%
    allocator_allocated:3114320
    allocator_active:3411968
    allocator_resident:10473472
    total_system_memory:8366104576
    total_system_memory_human:7.79G
    used_memory_lua:37888
    used_memory_lua_human:37.00K
    used_memory_scripts:0
    used_memory_scripts_human:0B
    number_of_cached_scripts:0
    maxmemory:0
    maxmemory_human:0B
    maxmemory_policy:noeviction
    allocator_frag_ratio:1.10
    allocator_frag_bytes:297648
    allocator_rss_ratio:3.07
    allocator_rss_bytes:7061504
    rss_overhead_ratio:1.19
    rss_overhead_bytes:2015232
    mem_fragmentation_ratio:4.77
    mem_fragmentation_bytes:9872056
    mem_not_counted_for_evict:82
    mem_replication_backlog:1048576
    mem_clients_slaves:16922
    mem_clients_normal:49694
    mem_aof_buffer:82
    mem_allocator:jemalloc-5.1.0
    active_defrag_running:0
    lazyfree_pending_objects:0
    
    # Persistence
    loading:0
    rdb_changes_since_last_save:2
    rdb_bgsave_in_progress:0
    rdb_last_save_time:1589149208
    rdb_last_bgsave_status:ok
    rdb_last_bgsave_time_sec:0
    rdb_current_bgsave_time_sec:-1
    rdb_last_cow_size:4530176
    aof_enabled:1
    aof_rewrite_in_progress:0
    aof_rewrite_scheduled:0
    aof_last_rewrite_time_sec:-1
    aof_current_rewrite_time_sec:-1
    aof_last_bgrewrite_status:ok
    aof_last_write_status:ok
    aof_last_cow_size:0
    aof_current_size:195
    aof_base_size:154
    aof_pending_rewrite:0
    aof_buffer_length:0
    aof_rewrite_buffer_length:0
    aof_pending_bio_fsync:0
    aof_delayed_fsync:0
    
    # Stats
    total_connections_received:34227
    total_commands_processed:153402
    instantaneous_ops_per_sec:1
    total_net_input_bytes:4832952
    total_net_output_bytes:2379022
    instantaneous_input_kbps:0.04
    instantaneous_output_kbps:0.00
    rejected_connections:0
    sync_full:1
    sync_partial_ok:0
    sync_partial_err:1
    expired_keys:0
    expired_stale_perc:0.00
    expired_time_cap_reached_count:0
    evicted_keys:0
    keyspace_hits:238
    keyspace_misses:0
    pubsub_channels:0
    pubsub_patterns:0
    latest_fork_usec:1043
    migrate_cached_sockets:0
    slave_expires_tracked_keys:0
    active_defrag_hits:0
    active_defrag_misses:0
    active_defrag_key_hits:0
    active_defrag_key_misses:0
    
    # Replication
    role:master
    connected_slaves:1
    slave0:ip=10.244.11.19,port=6379,state=online,offset=117585,lag=0
    master_replid:25b1900f429338f116f3534e9152bc5912037aba
    master_replid2:0000000000000000000000000000000000000000
    master_repl_offset:117585
    second_repl_offset:-1
    repl_backlog_active:1
    repl_backlog_size:1048576
    repl_backlog_first_byte_offset:1
    repl_backlog_histlen:117585
    
    # CPU
    used_cpu_sys:70.030822
    used_cpu_user:59.647139
    used_cpu_sys_children:0.079644
    used_cpu_user_children:0.143280
    
    # Cluster
    cluster_enabled:1
    
    # Keyspace
    Plugin Author Till Krüss

    (@tillkruess)

    Yeah, you’ll have to use the cluster constants. You can read more about that in the readme.

    Using

    define( 'WP_REDIS_CLUSTER', [
        'tcp://redis-cluster:6379?database=0&alias=node-01',
    ] );

    Instead of…

    define( 'WP_REDIS_HOST', 'redis-cluster' );

    I get…

    Connection Exception: Couldn't map cluster keyspace using any provided seed (RedisClusterException)

Viewing 15 replies - 1 through 15 (of 18 total)
  • You must be logged in to reply to this topic.