redis/redis-py · error · DataError

HIMPORT is not supported on the multi-database (Active-Activ

Error message

HIMPORT is not supported on the multi-database (Active-Active) client

What it means

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.

Source

Thrown at redis/asyncio/multidb/client.py:307

        """
        if not self.initialized:
            await self.initialize()

        return await self.command_executor.execute_command(*args, **options)

    # HIMPORT is not supported on the multi-database client. A HIMPORT fieldset is
    # per-connection server session state tracked by a single client's registry;
    # there is no coherent way to keep that state consistent across independent
    # database clients through failover. ``himport_set`` is inherited from
    # ``AsyncCoreCommands`` (and the lifecycle methods would otherwise be missing
    # entirely), so override them to fail early and clearly instead of surfacing a
    # confusing ``no such fieldset`` at runtime.
    _HIMPORT_UNSUPPORTED = (
        "HIMPORT is not supported on the multi-database (Active-Active) client"
    )

    async def himport_prepare(self, *args: Any, **kwargs: Any) -> Any:
        raise DataError(self._HIMPORT_UNSUPPORTED)

    async def himport_set(self, *args: Any, **kwargs: Any) -> Any:
        raise DataError(self._HIMPORT_UNSUPPORTED)

    async def himport_discard(self, *args: Any, **kwargs: Any) -> Any:
        raise DataError(self._HIMPORT_UNSUPPORTED)

    async def himport_discard_all(self, *args: Any, **kwargs: Any) -> Any:
        raise DataError(self._HIMPORT_UNSUPPORTED)

    def pipeline(self):
        """
        Enters into pipeline mode of the client.
        """
        return Pipeline(self)

    async def transaction(
        self,

View on GitHub (pinned to da03cdc7e8)

Solutions

  1. Do not use HIMPORT on MultiDBClient — use a direct `redis.asyncio.Redis` / `RedisCluster` client against a specific endpoint for HIMPORT workflows.
  2. If you need HIMPORT semantics, drop down to a single-database client and manage failover yourself.
  3. Review the comment block at redis/asyncio/multidb/client.py:295 for the design rationale.

Example fix

# before
client = MultiDBClient(cfg)
await client.himport_prepare('myset', fields=['a','b'])  # DataError

# after
import redis.asyncio as redis
single = redis.from_url('redis://host:6379/0')
await single.himport_prepare('myset', fields=['a','b'])
Defensive patterns

Strategy: validation

Validate before calling

def supports_himport(client) -> bool:
    # MultiDBClient intentionally blocks HIMPORT
    from redis.asyncio.multidb.client import MultiDBClient
    return not isinstance(client, MultiDBClient)

# only call himport_prepare when supports_himport(client) is True

Type guard

from redis.asyncio.multidb.client import MultiDBClient

def is_single_db_client(client) -> bool:
    # True for redis.asyncio.Redis / RedisCluster that support HIMPORT
    import redis.asyncio as aioredis
    return isinstance(client, (aioredis.Redis, aioredis.RedisCluster)) and not isinstance(client, MultiDBClient)

Try / catch

from redis.exceptions import DataError

try:
    await client.himport_prepare(...)
except DataError as e:
    if 'HIMPORT is not supported' in str(e):
        # route the call to a dedicated single-database client
        ...
    raise

Prevention

When it happens

Trigger: Calling `await client.himport_prepare(...)` on a `MultiDBClient` instance (inherited from AsyncCoreCommands but overridden to fail).

Common situations: 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.

Related errors


AI-assisted analysis of redis/redis-py@da03cdc7e8 (2026-08-04). Data as JSON: /data/errors/b35485010746754c.json. Report an issue: GitHub.