Skip to content

[Bug] Pipelining does not preserve positional integrity of replies #50

Description

@cryo2010

Summary

flushPipeline and exec return seq[string]:

https://github.com/nim-lang/redis/blob/a0f8216/src/redis.nim#L430
https://github.com/nim-lang/redis/blob/a0f8216/src/redis.nim#L1267

Flattening every reply to strings destroys information that pipeline
callers need:

  1. No 1:1 mapping. Status acknowledgments are filtered out and an
    empty array reply contributes zero strings, so N commands can
    produce fewer than N entries. Callers match results to commands by
    position, so any missing slot silently attributes every later result
    to the wrong command:

    r.multi()
    discard r.lRange("cart:items", 0, -1)    # empty list
    discard r.get("cart:owner")              # "alice"
    let res = r.exec()
    # res == @["alice"]: one entry for two commands, and it looks like
    # the answer to the lRange

    Pipelines are dominated by loop-generated batches (N runtime items,
    often several commands per item consumed in strides), where
    positional integrity is the entire contract.

  2. Type ambiguity. An integer reply of -1, a nil reply, and the
    literal strings "-1" and "" are indistinguishable after
    flattening, and redisNil ("\0\0") is an in-band sentinel that
    collides with real data.

  3. Structure loss. A reply that is an array of arrays arrives as
    one flat list with the boundaries erased.

These are properties of the seq[string] return type itself and cannot
be fixed behind the current signatures.

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