redis/redis-py · error · DataError

HIMPORT is not supported on the multi-database…

Error message

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

What it means

Raised as DataError by MultiDBClient.himport_prepare(). HIMPORT tracks per-connection server-side fieldset state that cannot be kept coherent across independent database clients during geographic failover, so the multi-database client deliberately disables all HIMPORT lifecycle methods rather than silently losing state. It fails fast at call time instead of producing a confusing server-side 'no such fieldset' later.

Solutions

  1. Do not use HIMPORT with the multi-database client; restructure the workload to use commands whose state is key-scoped (HSET, HGETDEL, etc.).
  2. If you genuinely need HIMPORT, bypass MultiDBClient and operate on a single underlying redis.asyncio.Redis client directly.
  3. Grep your codebase for himport_prepare/himport_set/himport_discard/himport_discard_all before migrating to MultiDBClient.
  4. Track this as a known unsupported surface in your client wrapper so callers get a typed error early.

Example fix

// before
fs = await client.himport_prepare("myset")  # DataError on MultiDBClient

// after - use key-scoped hashes instead
await client.hset("myhash", mapping={"f1": "v1"})
Defensive patterns

Strategy: type-guard

Validate before calling

def supports_himport(client) -> bool:
    # MultiDBClient (and its Pipeline) override the himport_* methods to raise
    return type(client).__name__ != "MultiDBClient"

if supports_himport(client):
    await client.himport_prepare("myset")
else:
    raise NotImplementedError("HIMPORT is not supported on the multi-database client")

Type guard

from redis.asyncio.multidb.client import MultiDBClient

def is_multidb_client(client) -> bool:
    return isinstance(client, MultiDBClient)

Try / catch

from redis.exceptions import DataError

try:
    await client.himport_prepare("myset")
except DataError as e:
    if "HIMPORT is not supported" in str(e):
        # fall back to key-scoped hash commands
        await client.hset("myhash", mapping=mapping)
    else:
        raise

Prevention

When it happens

Trigger: Calling await client.himport_prepare(...) (or, via the inherited AsyncCoreCommands surface, anything that resolves to HIMPORT PREPARE) on a MultiDBClient instance. The override at client.py:306-307 unconditionally raises before any wire traffic.

Common situations: Porting code from a plain redis.asyncio.Redis client to MultiDBClient for Active-Active failover without removing HIMPORT usage; IDE autocompletion suggesting himport_* because they are inherited from AsyncCoreCommands.

Related errors


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

Appendix: 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 6a6b581b48)