redis/redis · error

Error fetching random members\n

Error message

Error fetching random members\n

What it means

Inside the recall loop, `VRANDMEMBER <key> <count>` returned NULL, a non-array, or an empty array (redis-cli.c:9050), so the test cannot build query vectors and `exit(1)`s. Causes include a lost connection mid-run, the key being emptied or retyped, or a count larger than available elements.

Source

Thrown at src/redis-cli.c:9052

    }
    unsigned int dim = reply->integer;
    freeReplyObject(reply);

    printf("\n# Testing recall for vector set: %s (dimension: %d)\n",
           config.vset_recall_key, dim);
    printf("# Mixing %d random element vectors, top %d results, EF=%d\n\n",
           ele_count, vsim_count, vsim_ef);

    signal(SIGINT, longStatLoopModeStop);

    /* Do the same recall test again and again. */
    while (force_cancel_loop == 0) {
        /* Get random members. */
        reply = reconnectingRedisCommand(context, "VRANDMEMBER %s %d",
                                        config.vset_recall_key, ele_count);
        if (reply == NULL || reply->type != REDIS_REPLY_ARRAY ||
            reply->elements == 0) {
            fprintf(stderr, "Error fetching random members\n");
            exit(1);
        }

        /* Fetch and store vectors. */
        double **vectors = zmalloc(reply->elements * sizeof(double*));
        int valid_vectors = 0;

        for (size_t i = 0; i < reply->elements; i++) {
            redisReply *vemb = reconnectingRedisCommand(context, "VEMB %s %s",
                                                       config.vset_recall_key,
                                                       reply->element[i]->str);
            if (vemb && vemb->type == REDIS_REPLY_ARRAY &&
                vemb->elements == dim) {
                vectors[valid_vectors] = zmalloc(dim * sizeof(double));
                for (unsigned int j = 0; j < dim; j++) {
                    vectors[valid_vectors][j] = atof(vemb->element[j]->str);
                }
                valid_vectors++;

View on GitHub (pinned to 4f20cb4893)

Solutions

  1. Keep the key populated and stable for the duration of the run.
  2. Lower `--vset-recall-ele-count` to be <= the current member count.
  3. Ensure a stable connection; run on a host with a reliable link to Redis.

Example fix

// before
redis-cli --vset-recall --vset-recall-key myset --vset-recall-ele-count 1000   # set has 50
// after
redis-cli --vset-recall --vset-recall-key myset --vset-recall-ele-count 50
Defensive patterns

Strategy: validation

Validate before calling

# Ensure the key has enough members for the requested sample count
members=$(redis-cli -h "$HOST" -p "$PORT" -n "$DB" VCARD "$KEY" 2>/dev/null)
[ "${members:-0}" -ge "$ELE_COUNT" ] || { echo "not enough members ($members < $ELE_COUNT)"; exit 2; }
redis-cli --vset-recall --vset-recall-key "$KEY" --vset-recall-ele-count "$ELE_COUNT"

Try / catch

if ! redis-cli --vset-recall --vset-recall-key "$KEY" --vset-recall-ele-count "$N"; then
  echo "recall failed; keep the key populated and ensure N <= member count" >&2
  exit 1
fi

Prevention

When it happens

Trigger: The vector set was flushed/emptied during the run, count exceeds the set size, or the connection dropped.

Common situations: Concurrent writes/deletes on the key, network interruption, or `--vset-recall-ele-count` set higher than the member count.

Related errors


AI-assisted analysis of redis/redis@4f20cb4893 (2026-08-10). Data as JSON: /api/errors/3d4c258e3e90c991. Report an issue: GitHub.