{"id":"857963c7f5d1c0fb","repo":"redis/redis-py","slug":"could-not-find-a-matching-bdb","errorCode":null,"errorMessage":"Could not find a matching bdb","messagePattern":"Could not find a matching bdb","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/multidb/healthcheck.py","lineNumber":499,"sourceCode":"        self._http_client.client.base_url = base_url\n\n        # Find bdb matching to the current database host\n        matching_bdb = None\n        for bdb in await self._http_client.get(\"/v1/bdbs\"):\n            for endpoint in bdb[\"endpoints\"]:\n                if endpoint[\"dns_name\"] == db_host:\n                    matching_bdb = bdb\n                    break\n\n                # In case if the host was set as public IP\n                for addr in endpoint[\"addr\"]:\n                    if addr == db_host:\n                        matching_bdb = bdb\n                        break\n\n        if matching_bdb is None:\n            logger.warning(\"LagAwareHealthCheck failed: Couldn't find a matching bdb\")\n            raise ValueError(\"Could not find a matching bdb\")\n\n        url = (\n            f\"/v1/bdbs/{matching_bdb['uid']}/availability\"\n            f\"?extend_check=lag&availability_lag_tolerance_ms={self._lag_aware_tolerance}\"\n        )\n        await self._http_client.get(url, expect_json=False)\n\n        # Status checked in an http client, otherwise HttpError will be raised\n        return True\n","sourceCodeStart":481,"sourceCodeEnd":509,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/multidb/healthcheck.py#L481-L509","documentation":"Raised by LagAwareHealthCheck.check_health (redis/asyncio/multidb/healthcheck.py:499) after querying /v1/bdbs on the Redis Enterprise REST API and finding no database (bdb) whose endpoint dns_name or addr matches the host the client is connected to. The client's configured host and the cluster's registered endpoints disagree.","triggerScenarios":"Client connected to an IP/hostname that is not registered as an endpoint dns_name or addr on any bdb in the Enterprise cluster; using a load-balancer or public IP not listed in the cluster's bdb endpoints; stale cluster state after a migration.","commonSituations":"Connecting through an external LB/FQDN while the REST API only knows internal endpoint names; pointing the client at the wrong cluster than the one the REST API is queried against; DNS drift after failover.","solutions":["Make the client's host exactly match a dns_name (or an addr entry) reported by GET /v1/bdbs on the same REST API.","Query /v1/bdbs yourself and set the DatabaseConfig client host to a registered endpoint.","Confirm health_check_url and the client host refer to the same Redis Enterprise cluster."],"exampleFix":"# before\nclient = AsyncRedis(host=\"public-lb.example.com\", port=12000)\n# no bdb endpoint matches 'public-lb.example.com'\n# after\nclient = AsyncRedis(host=\"us1-db1.rec.local\", port=12000)  # matches bdb endpoint dns_name","handlingStrategy":"validation","validationCode":"bdbs = await http.get(f'{base_url}/v1/bdbs')\nknown_hosts = {ep['dns_name'] for b in bdbs for ep in b['endpoints']} | {a for b in bdbs for ep in b['endpoints'] for a in ep['addr']}\nassert client_host in known_hosts, f'{client_host} not registered as a bdb endpoint'","typeGuard":"def host_matches_bdb(host: str, bdbs: list) -> bool:\n    return any(host == ep.get('dns_name') or host in ep.get('addr', []) for b in bdbs for ep in b.get('endpoints', []))","tryCatchPattern":"try:\n    await lag_hc.check_health(database, client)\nexcept ValueError as e:\n    logger.warning('bdb match failed for %s: %s', client_host, e)\n    raise","preventionTips":["Keep the client host identical to a registered bdb endpoint dns_name.","Do not route the client through an LB IP the cluster does not know about."],"tags":["config","redis-enterprise","healthcheck","multidb"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}