Skip to content

Commit

Permalink
fix: swap blocked list chain missing key when multiple client blocked…
Browse files Browse the repository at this point in the history
… on single key.
  • Loading branch information
patpatbear committed Apr 11, 2024
1 parent cd5dc44 commit 377075d
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/ctrip_swap_blocked.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ swapUnblockCtx* createSwapUnblockCtx() {
client *c = createClient(NULL);
c->cmd = lookupCommandByCString("brpoplpush");
c->db = server.db+i;
c->client_hold_mode = CLIENT_HOLD_MODE_EVICT;
swap_dependency_block_ctx->mock_clients[i] = c;
}
return swap_dependency_block_ctx;
Expand All @@ -100,18 +101,13 @@ void releaseSwapUnblockCtx(swapUnblockCtx* swap_dependency_block_ctx) {
void findSwapBlockedListKeyChain(redisDb* db, robj* key, dict* key_sets) {
dictEntry *de = dictFind(db->blocking_keys,key);
if(de) {
listIter li;
listNode *ln;
list *clients = dictGetVal(de);
int numclients = listLength(clients);
while(numclients--) {
listNode *clientnode = listFirst(clients);
client *receiver = clientnode->value;

if (receiver->btype != BLOCKED_LIST) {
/* Put at the tail, so that at the next call
* we'll not run into it again. */
listRotateHeadToTail(clients);
continue;
}
listRewind(clients,&li);
while ((ln = listNext(&li))) {
client *receiver = listNodeValue(ln);
if (receiver->btype != BLOCKED_LIST) continue;
robj *dstkey = receiver->bpop.target;
if (dstkey == NULL || dictAdd(key_sets, dstkey, NULL) != C_OK) continue;
incrRefCount(dstkey);
Expand Down

0 comments on commit 377075d

Please sign in to comment.