redis/redis-py · error · ValueError

Could not find a matching bdb

Error message

Could not find a matching bdb

What it means

Raised as a ValueError in LagAwareHealthCheck.check_health after iterating all bdbs returned by the Redis Enterprise /v1/bdbs endpoint and finding none whose endpoint dns_name or addr matches the host the client is currently connected to. The health checker cannot correlate the live connection to a tracked database, so it cannot look up availability/lag. This usually indicates a mismatch between the connection target and what the REST API reports.

Solutions

  1. Ensure the client connects to the exact host (DNS name or IP) listed in the bdb endpoints on the Redis Enterprise admin UI/API.
  2. Refresh the /v1/bdbs listing and confirm the database still exists and its endpoint matches db_host.
  3. If connecting through a proxy, add the proxy's host to the bdb endpoint addr list or connect directly.

Example fix

# before
client = AsyncRedis(host="10.0.0.99")  # not in any bdb endpoint
# after
client = AsyncRedis(host="redis-12345.cluster.local")  # matches bdb endpoint dns_name
Defensive patterns

Strategy: try-catch

Validate before calling

host = database.client.get_connection_kwargs()["host"]
bdbs = await http_client.get("/v1/bdbs")
known_hosts = {ep["dns_name"] for b in bdbs for ep in b["endpoints"]}
known_hosts |= {a for b in bdbs for ep in b["endpoints"] for a in ep["addr"]}
if host not in known_hosts:
    raise ValueError(f"client host {host} not in any bdb endpoint")

Try / catch

try:
    await lag_hc.check_health(database, client)
except ValueError as e:
    if "matching bdb" in str(e):
        logger.warning("bdb match failed for host; check REST API endpoints")
    else:
        raise

Prevention

When it happens

Trigger: check_health() runs, fetches /v1/bdbs, and every bdb's endpoint dns_name and addr list differ from the client's resolved host (db_host taken from client.get_connection_kwargs()['host'] for a standalone client or get_nodes()[0].host for a cluster client).

Common situations: Connecting via a public IP while the REST API only lists internal DNS names (the code checks both, but a NAT/different IP still misses). Using a load balancer or proxy host that does not appear in the bdb endpoint list. Stale REST API state after a database was recreated with a new uid/endpoints.

Related errors


AI-assisted analysis of redis/redis-py@6a6b581b48 (2026-08-10). Data as JSON: /api/errors/857963c7f5d1c0fb. Report an issue: GitHub.

Appendix: source

Thrown at redis/asyncio/multidb/healthcheck.py:499

        self._http_client.client.base_url = base_url

        # Find bdb matching to the current database host
        matching_bdb = None
        for bdb in await self._http_client.get("/v1/bdbs"):
            for endpoint in bdb["endpoints"]:
                if endpoint["dns_name"] == db_host:
                    matching_bdb = bdb
                    break

                # In case if the host was set as public IP
                for addr in endpoint["addr"]:
                    if addr == db_host:
                        matching_bdb = bdb
                        break

        if matching_bdb is None:
            logger.warning("LagAwareHealthCheck failed: Couldn't find a matching bdb")
            raise ValueError("Could not find a matching bdb")

        url = (
            f"/v1/bdbs/{matching_bdb['uid']}/availability"
            f"?extend_check=lag&availability_lag_tolerance_ms={self._lag_aware_tolerance}"
        )
        await self._http_client.get(url, expect_json=False)

        # Status checked in an http client, otherwise HttpError will be raised
        return True

View on GitHub (pinned to 6a6b581b48)