Skip to content

Use Redis Sentinel for Caching/Async Queries #783

Description

@maltesander

Description

The PR #724 added celery worker support using Redis following the standard Superset example: https://superset.apache.org/admin-docs/configuration/async-queries-celery/

  • This only works for RedisCache not RedisSentinelCache
  • The schema used is always redis:// instead of sentinel://
  • The master-name cannot be configured for sentinel nodes

So Redis in HA mode is not available without overrides (not tested).

Possible untested fix

configOverrides:
  superset_config.py:
    FILE_FOOTER: |
      from flask_caching.backends.rediscache import RedisSentinelCache
      _SENTINELS = [("redis-sentinel-0.redis-sentinel-headless", 26379),
                    ("redis-sentinel-1.redis-sentinel-headless", 26379),
                    ("redis-sentinel-2.redis-sentinel-headless", 26379)]
      _MASTER = "mymaster"
      _PW = os.environ["CELERY_RESULTS_BACKEND_DATABASE_PASSWORD"]

      RESULTS_BACKEND = RedisSentinelCache(
          sentinels=_SENTINELS, master=_MASTER, password=_PW, db=0,
          key_prefix="superset_results",
          # sentinel_password=..., only if the sentinels themselves require auth
      )

      _URL = ";".join(f"sentinel://:{_PW}@{h}:{p}" for h, p in _SENTINELS) + "/0"
      class CeleryConfig(object):
          broker_url = _URL
          result_backend = _URL
          broker_transport_options = {"master_name": _MASTER}
          result_backend_transport_options = {"master_name": _MASTER}
          imports = ("superset.sql_lab", "superset.tasks.scheduler")
          worker_prefetch_multiplier = 10
          task_acks_late = True
          task_annotations = {"sql_lab.get_sql_results": {"rate_limit": "100/s"}}
      CELERY_CONFIG = CeleryConfig

This is just a workaround and will need adaptation whenever the redis replicas change.

Issue checklist

This is a simple checklist of things to bear in mind when creating a new issue.

  • Describe the use-case: As far as possible, use the pattern "As a [type of user], I would like [feature/functionality] to be able to do [specific action]." This helps identify the feature and the problem it addresses.
  • Indicate importance and urgency: Use a scale (e.g., low, medium, high) to indicate the level of importance and urgency.
  • Work-around: If there is a known work-around, describe it briefly.
  • Environment: Describe the environment where the issue occurs (e.g., SDP version, K8S version, etc.).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions