Reputation: 23
When using LPOP if the client drops the connection when redis server is executing the command, what happens to the item being popped?
More specifically, does the item gets dropped even though it was not delivered or is it kept in memory as command didn't succeed?
Thanks for any help/pointers.
Upvotes: 0
Views: 134
Reputation: 49283
The part of the code that handles the actual logic of popping, is oblivious to the client state. Redis will not wait for the response send to complete in order to finish processing the command. It will be very slow if it waited like so, especially being single threaded.
You can take a look at the part of the code that handles BLPOP to see how this happens:
// here is where redis actually pops from the list
robj *value = listTypePop(o,where);
serverAssert(value != NULL);
// now it ads the reply to the client's queue (c is the client)
// but as you can see there is no return code from these methods
// and redis doesn't actually send anything when addReply is called
addReplyMultiBulkLen(c,2);
addReplyBulk(c,c->argv[j]);
addReplyBulk(c,value);
Upvotes: 1