Skip to content

setting ttl delete the pipeline commands (cluster+async) #417

@dfroger

Description

@dfroger

Here is my example to reproduce, using redis==6.4.0 and redisvl==0.10.0 (docker-compose.yml to reproduce here):

import asyncio
import struct

from redis.asyncio.cluster import ClusterNode, RedisCluster
from redisvl.index import AsyncSearchIndex
from redisvl.schema import IndexSchema


SCHEMA = IndexSchema.from_dict(
    {
        "index": {
            "name": "user-index",
            "prefix": "user:",
        },
        "fields": [
            {"name": "user", "type": "tag"},
            {"name": "credit_score", "type": "tag"},
            {
                "name": "embedding",
                "type": "vector",
                "attrs": {
                    "algorithm": "flat",
                    "dims": 3,
                    "distance_metric": "cosine",
                    "datatype": "float32",
                },
            },
        ],
    }
)


async def client():
    index = AsyncSearchIndex(
        SCHEMA,
        redis_client=RedisCluster(
            startup_nodes=[ClusterNode(host="redis-1", port=6379)],
            username=None,
            password=None,
            client_name="client-issue",
        ),
    )
    await index.client.initialize()
    await index.create()
    keys = await index.load(
        [
            {
                "user": "bob",
                "credit_score": "good",
                "embedding": struct.pack("3f", 0.1, 0.2, 0.3),
            }
        ],
        keys=["user:bob"],
        ttl=3600
    )
    print(f"Inserted: {keys}", flush=True)


asyncio.run(client())

Here, nothing is inserted because await pipe.expire() triggers ClusterPipeline.__await__ which empties the command queue.

What is wrong here?

  • If there is something wrong in my code example, would be nice to get an error during the initialization.
  • If this is a bug in redis-vl, is it the await to remove in await pipe.expire(), or something else?
  • By the way, what is the purpose of ClusterPipeline.__await__ in redis-py?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions