Bugfix: Make modules blocked on keys unblock on commands like LPUSH#8356
Bugfix: Make modules blocked on keys unblock on commands like LPUSH#8356oranagra merged 4 commits intoredis:unstablefrom
Conversation
This makes it possible to implement blocking list and zset commands using the modules API. It is already supposed to work like this according to the Modules API reference in the documentation for RedisModule_BlockClientOnKeys(): > If you block on a key of a type that has blocking operations > associated, like a list, a sorted set, a stream, and so forth, > the client may be unblocked once the relevant key is targeted > by an operation that normally unblocks the native blocking > operations for that type. This commit also includes a test case for the reverse: A module unblocks a client blocked on BLPOP by inserting elements using RedisModule_ListPush(). This already works, but it was untested.
|
seems that this is a regression from #7625 (@yangbodong22011 FYI) |
yangbodong22011
left a comment
There was a problem hiding this comment.
@zuiderkwast thanks for your fix, I spent some time to understand your fix, and I have some suggestions for comments to make it easier for others to understand why BLOCKED_MODULE needs to be judged separately.
|
@zuiderkwast just to be sure. please test it with valgrind: |
$rd close Co-authored-by: Oran Agra <[email protected]>
|
It passed with valgrind. |
|
Side note: There's a test case called "Module client blocked on keys does not wake up on wrong type" which you would assume is broken now. It is however still passing because if the key is of wrong type, it goes back to blocking ( |
|
@guybe7 please have a look (at both this PR, and the above comment) |
|
@oranagra PR looks good |
Yes, I suppose it was.
Sounds good. But the new test case that I added in this PR also checks that a module can wake up by an LPUSH. Anyway, it's good to test that returning ERR makes it go back to sleep and wakes up again later. |
…edis#8356) This was a regression from redis#7625 (only in 6.2 RC2). This makes it possible again to implement blocking list and zset commands using the modules API. This commit also includes a test case for the reverse: A module unblocks a client blocked on BLPOP by inserting elements using RedisModule_ListPush(). This already works, but it was untested.
This makes it possible to implement blocking list and zset commands
using the modules API.
It is already supposed to work like this according to the Modules API
reference in the documentation for RedisModule_BlockClientOnKeys():
This commit also includes a test case for the reverse: A module
unblocks a client blocked on BLPOP by inserting elements using
RedisModule_ListPush(). This already works, but it was untested.