The documentation on -ASK at https://redis.io/topics/cluster-spec reads..
Basically the ASKING command sets a one-time flag on the client that forces a node to serve a query about an IMPORTING slot.
The full semantics of ASK redirection from the point of view of the client is as follows:
- If ASK redirection is received, send only the query that was redirected to the specified node but continue sending subsequent queries to the old node.
- Start the redirected query with the ASKING command.
But in the case of pipelined commands, say I send (assume serialized) GET {ABC}.a \r\n GET {ABC}.b \r\n and get back two -ASK error responses.
Firstly, what is the correct response syntax... ASKING GET {ABC}.a \r\n ASKING GET {ABC}.b \r\n ??
And secondly, the documentation that says "sets a one-time flag" makes me wonder whether this is implemented as a true flag or a counter. Will that 1st ASKING trigger a MOVED because the 2nd command stole its spot? Or will Redis know to accept 2 ASKING commands for that slot? And is this ASKING-acceptance check done according to exact string match, or hashslot?
Comment From: victorstewart
For anyone else who finds this.... I dug into the server code to answer my own questions.
if you send GET {ABC}.a \r\n to node A and receive back -ASK, the correct response syntax to node B is ASKING \r\n GET {ABC}.a \r\n.
That ASKING command is what sets the accept the next command that targets a migrating hashslot, and that flag is always cleared by the next command (unless the next command were another ASKING).
Comment From: itamarhaber
@victorstewart please feel free to expand and clarify on the documentation (https://github.com/antirez/redis-doc) if needed.