Module unblock on keys: updateStatsOnUnblock is called twice#13405
Merged
sundb merged 5 commits intoredis:unstablefrom Jul 11, 2024
Merged
Module unblock on keys: updateStatsOnUnblock is called twice#13405sundb merged 5 commits intoredis:unstablefrom
sundb merged 5 commits intoredis:unstablefrom
Conversation
This commit reverts the deletion of the condition '!bc->blocked_on_keys' which was accidently introduced by redis#12817 In case a module blocked-on-keys client is unblocked both 'moduleUnblockClientOnKey' and 'moduleHandleBlockedClients' are called which resulted in 'updateStatsOnUnblock' being called twice
Collaborator
|
@guybe7 thanks, but i forget why i deleted it, please let me recall it. |
sundb
reviewed
Jul 10, 2024
sundb
reviewed
Jul 10, 2024
Co-authored-by: debing.sun <[email protected]>
Collaborator
|
@guybe7 from the report of ASAN thread, i dont see new race condition issue. |
Collaborator
Author
|
@sundb can we merge it? |
sundb
approved these changes
Jul 11, 2024
sundb
added a commit
to YaacovHazan/redis
that referenced
this pull request
Apr 22, 2025
…3405) This commit reverts the deletion of the condition `!bc->blocked_on_keys` that was accidentally introduced by redis#12817. In case a blocked-on-keys module client is unblocked both `moduleUnblockClientOnKey` and `moduleHandleBlockedClients` are called which resulted in `updateStatsOnUnblock` being called twice Now, that `moduleHandleBlockedClients` doesn't call `updateStatsOnUnblock` in case of unblocked module key-blocked clients, in the unlikely event that the module decides to call `RM_UnblockClient` on a key-blocked client, we need to call `updateStatsOnUnblock` from within `moduleBlockedClientTimedOut`, but since `moduleBlockedClientTimedOut` is not tread-safe we can't call it directly from withing `RM_UnblockClient`. Added a new flag `blocked_on_keys_explicit_unblock` for that specific case, which will cause `moduleBlockedClientTimedOut` to be called from `moduleHandleBlockedClients` (which is only called from the main thread) --------- Co-authored-by: debing.sun <[email protected]>
funny-dog
pushed a commit
to funny-dog/redis
that referenced
this pull request
Sep 17, 2025
…3405) This commit reverts the deletion of the condition `!bc->blocked_on_keys` that was accidentally introduced by redis#12817. In case a blocked-on-keys module client is unblocked both `moduleUnblockClientOnKey` and `moduleHandleBlockedClients` are called which resulted in `updateStatsOnUnblock` being called twice Now, that `moduleHandleBlockedClients` doesn't call `updateStatsOnUnblock` in case of unblocked module key-blocked clients, in the unlikely event that the module decides to call `RM_UnblockClient` on a key-blocked client, we need to call `updateStatsOnUnblock` from within `moduleBlockedClientTimedOut`, but since `moduleBlockedClientTimedOut` is not tread-safe we can't call it directly from withing `RM_UnblockClient`. Added a new flag `blocked_on_keys_explicit_unblock` for that specific case, which will cause `moduleBlockedClientTimedOut` to be called from `moduleHandleBlockedClients` (which is only called from the main thread) --------- Co-authored-by: debing.sun <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit reverts the deletion of the condition
!bc->blocked_on_keysthat was accidentally introduced by #12817.In case a blocked-on-keys module client is unblocked both
moduleUnblockClientOnKeyandmoduleHandleBlockedClientsare called which resulted inupdateStatsOnUnblockbeing called twiceNow, that
moduleHandleBlockedClientsdoesn't callupdateStatsOnUnblockin case of unblocked module key-blocked clients, in the unlikely event that the module decides to callRM_UnblockClienton a key-blocked client, we need to callupdateStatsOnUnblockfrom withinmoduleBlockedClientTimedOut, but sincemoduleBlockedClientTimedOutis not tread-safe we can't call it directly from withingRM_UnblockClient.Added a new flag
blocked_on_keys_explicit_unblockfor that specific case, which will causemoduleBlockedClientTimedOutto be called frommoduleHandleBlockedClients(which is only called from the main thread)