Skip to content

ClusterAllFailedError: Failed to refresh slots cache when using standalone Redis #1868

Description

@defame-flagstick

Hi folks,

I am trying to run Ghost ActivityPub with a standard standalone Redis container (redis:alpine) in Docker Compose. When setting FEDIFY_KV_STORE_TYPE: redis, the application crashes with an Unhandled error event: ClusterAllFailedError: Failed to refresh slots cache loop.

It seems that ioredis is internally trying to connect to a Redis Cluster (new Redis.Cluster()) instead of a single standalone Redis node. This causes it to fail because a standalone instance cannot return cluster slots.

Error Log

09:45:51.047 WRN activitypub: Redis connection retry attempt 23, delay 1150ms
[ioredis] Unhandled error event: ClusterAllFailedError: Failed to refresh slots cache.
    at tryNode (/opt/activitypub/node_modules/ioredis/built/cluster/index.js:335:31)
    at /opt/activitypub/node_modules/ioredis/built/cluster/index.js:352:21
    at /opt/activitypub/node_modules/ioredis/built/cluster/index.js:721:24
    at run (/opt/activitypub/node_modules/ioredis/built/utils/index.js:119:22)
    at tryCatcher (/opt/activitypub/node_modules/standard-as-callback/built/utils.js:12:23)
    at /opt/activitypub/node_modules/standard-as-callback/built/index.js:33:51
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
09:45:52.202 WRN activitypub: Redis connection retry attempt 24, delay 1200ms

Docker Compose Snippet

Here is the relevant part of my docker-compose.yml:

   activitypub:
     image: ghcr.io/tryghost/activitypub:1.2.5@sha256:15dab1c0d16f1deace5e261b42519e80739db47c1a4dbb51c6ded01acabd26a0
     container_name: \${CONTAINER_APP_NAME}_activitypub
     restart: unless-stopped
     expose:
       - "8080"
     volumes:
       - \${GHOST_AP_PATH}:/opt/activitypub/content
     depends_on:
       db:
         condition: service_healthy
       activitypub-migrate:
         condition: service_completed_successfully
       redis:
         condition: service_started
     environment:
       NODE_ENV: production
       PORT: 8080
       MYSQL_HOST: \${CONTAINER_DB_NAME}
       MYSQL_PORT: 3306
       MYSQL_USER: \${AP_MYSQL_USER}
       MYSQL_PASSWORD: \${AP_MYSQL_PASSWORD}
       MYSQL_DATABASE: \${AP_MYSQL_DATABASE}
       LOCAL_STORAGE_PATH: /opt/activitypub/content/images/activitypub
       LOCAL_STORAGE_HOSTING_URL: https://\${DOMAIN_MAIN}/content/images/activitypub
       FEDIFY_KV_STORE_TYPE: redis
       REDIS_HOST: \${CONTAINER_APP_NAME}_redis
       REDIS_PORT: 6379
     deploy:
       resources:
         limits:
           memory: 300M
     networks:
       - proxy_network
       - redis_network

  redis:
     image: redis:alpine
     restart: unless-stopped
     container_name: \${CONTAINER_APP_NAME}_redis
     volumes:
       - \${GHOST_REDIS_PATH}:/data
     labels:
       - "com.centurylinklabs.watchtower.enable=true"
     logging:
       options:
         max-size: \${LOGGING_OPTIONS_MAX_SIZE:-200k}
     networks:
       - redis_network

Request for Action

Could you please check if the ioredis initialization in the codebase can be adapted to support standalone single-node Redis configurations rather than forcing Cluster mode?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions