{"id":"b35485010746754c","repo":"redis/redis-py","slug":"himport-is-not-supported-on-the-multi-database-ac","errorCode":null,"errorMessage":"HIMPORT is not supported on the multi-database (Active-Active) client","messagePattern":"HIMPORT is not supported on the multi-database \\(Active-Active\\) client","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/asyncio/multidb/client.py","lineNumber":307,"sourceCode":"        \"\"\"\n        if not self.initialized:\n            await self.initialize()\n\n        return await self.command_executor.execute_command(*args, **options)\n\n    # HIMPORT is not supported on the multi-database client. A HIMPORT fieldset is\n    # per-connection server session state tracked by a single client's registry;\n    # there is no coherent way to keep that state consistent across independent\n    # database clients through failover. ``himport_set`` is inherited from\n    # ``AsyncCoreCommands`` (and the lifecycle methods would otherwise be missing\n    # entirely), so override them to fail early and clearly instead of surfacing a\n    # confusing ``no such fieldset`` at runtime.\n    _HIMPORT_UNSUPPORTED = (\n        \"HIMPORT is not supported on the multi-database (Active-Active) client\"\n    )\n\n    async def himport_prepare(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    async def himport_set(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    async def himport_discard(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    async def himport_discard_all(self, *args: Any, **kwargs: Any) -> Any:\n        raise DataError(self._HIMPORT_UNSUPPORTED)\n\n    def pipeline(self):\n        \"\"\"\n        Enters into pipeline mode of the client.\n        \"\"\"\n        return Pipeline(self)\n\n    async def transaction(\n        self,","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/redis/redis-py/blob/da03cdc7e8731092b13e395605c3c1fb2de25de1/redis/asyncio/multidb/client.py#L289-L325","documentation":"Raised by `MultiDBClient.himport_prepare()` (redis/asyncio/multidb/client.py:307). HIMPORT uses a per-connection server-side fieldset registry that cannot be kept coherent across independent database clients during failover, so the MultiDBClient deliberately blocks the entire HIMPORT lifecycle with DataError rather than silently misbehaving after a failover.","triggerScenarios":"Calling `await client.himport_prepare(...)` on a `MultiDBClient` instance (inherited from AsyncCoreCommands but overridden to fail).","commonSituations":"Porting code that uses HIMPORT (Active-Active conflict-free field updates) to the MultiDBClient without realizing the multi-database client cannot track per-connection fieldset state.","solutions":["Do not use HIMPORT on MultiDBClient — use a direct `redis.asyncio.Redis` / `RedisCluster` client against a specific endpoint for HIMPORT workflows.","If you need HIMPORT semantics, drop down to a single-database client and manage failover yourself.","Review the comment block at redis/asyncio/multidb/client.py:295 for the design rationale."],"exampleFix":"# before\nclient = MultiDBClient(cfg)\nawait client.himport_prepare('myset', fields=['a','b'])  # DataError\n\n# after\nimport redis.asyncio as redis\nsingle = redis.from_url('redis://host:6379/0')\nawait single.himport_prepare('myset', fields=['a','b'])","handlingStrategy":"validation","validationCode":"def supports_himport(client) -> bool:\n    # MultiDBClient intentionally blocks HIMPORT\n    from redis.asyncio.multidb.client import MultiDBClient\n    return not isinstance(client, MultiDBClient)\n\n# only call himport_prepare when supports_himport(client) is True","typeGuard":"from redis.asyncio.multidb.client import MultiDBClient\n\ndef is_single_db_client(client) -> bool:\n    # True for redis.asyncio.Redis / RedisCluster that support HIMPORT\n    import redis.asyncio as aioredis\n    return isinstance(client, (aioredis.Redis, aioredis.RedisCluster)) and not isinstance(client, MultiDBClient)","tryCatchPattern":"from redis.exceptions import DataError\n\ntry:\n    await client.himport_prepare(...)\nexcept DataError as e:\n    if 'HIMPORT is not supported' in str(e):\n        # route the call to a dedicated single-database client\n        ...\n    raise","preventionTips":["Keep HIMPORT workflows on a dedicated single-database client, never on MultiDBClient.","Static type-check with isinstance(client, MultiDBClient) before calling HIMPORT methods.","Document in service code which client types each HIMPORT call site uses."],"tags":["multidb","himport","unsupported","active-active"],"analyzedSha":"da03cdc7e8731092b13e395605c3c1fb2de25de1","analyzedAt":"2026-08-04T20:26:47.563Z","schemaVersion":2}