HFE - Avoid lazy expire if called by modules + cleanup#13326
Merged
moticless merged 9 commits intoredis:unstablefrom Jun 10, 2024
Merged
HFE - Avoid lazy expire if called by modules + cleanup#13326moticless merged 9 commits intoredis:unstablefrom
moticless merged 9 commits intoredis:unstablefrom
Conversation
sundb
reviewed
Jun 6, 2024
tezc
reviewed
Jun 6, 2024
sundb
reviewed
Jun 6, 2024
tezc
previously approved these changes
Jun 6, 2024
sundb
previously approved these changes
Jun 6, 2024
tezc
reviewed
Jun 10, 2024
tezc
reviewed
Jun 10, 2024
tezc
approved these changes
Jun 10, 2024
Merged
YaacovHazan
added a commit
that referenced
this pull request
Jun 27, 2024
Upgrade urgency LOW: This is the second Release Candidate for Redis 7.4. Performance and resource utilization improvements ================================================= * #13296 Optimize CPU cache efficiency Changes to new 7.4 new features (compared to 7.4 RC1) ===================================================== * #13343 Hash - expiration of individual fields: when key does not exist - reply with an array (nonexisting code for each field) * #13329 Hash - expiration of individual fields: new keyspace event: `hexpired` Modules API - Potentially breaking changes to new 7.4 features (compared to 7.4 RC1) ==================================================================================== * #13326 Hash - expiration of individual fields: avoid lazy expire when called from a Modules API function
guybe7
reviewed
Oct 23, 2024
| * field and the command was sent with XX flag, the operation could | ||
| * fail and leave the hash empty, which the caller might not expect. | ||
| * To prevent unexpected behavior, we avoid lazy deletion in this case | ||
| * yet let the operation fail. Note that moduleDelKeyIfEmpty() |
Collaborator
There was a problem hiding this comment.
it seems that using direct key API can potentially delete the key (e.g. RM_ZsetRem) so why do we have a problem with RM_HashGet/Set deleting the key?
guybe7
reviewed
Oct 23, 2024
Comment on lines
+5285
to
+5286
| if (flags & REDISMODULE_HASH_XX) | ||
| hfeFlags |= HFE_LAZY_AVOID_FIELD_DEL; |
Collaborator
There was a problem hiding this comment.
why even bother deleting the field when using NX? anyway, if it's logically expired we are going to override it with hashTypeSet below
guybe7
reviewed
Oct 23, 2024
| if (flags & REDISMODULE_HASH_XX) | ||
| hfeFlags |= HFE_LAZY_AVOID_FIELD_DEL; | ||
|
|
||
| int exists = hashTypeExists(key->db, key->value, field->ptr, hfeFlags, NULL); |
Collaborator
There was a problem hiding this comment.
please note that hashTypeExists/hashTypeGetValue should be called with HFE_LAZY_NO_NOTIFICATION because direct key API doesn't emit notifications (by design)
funny-dog
pushed a commit
to funny-dog/redis
that referenced
this pull request
Sep 17, 2025
Need to be carefull if called by modules since modules API allow to open and close key handler. We don't want to invalidate the handler underneath. * hashTypeExists(), hashTypeGetValueObject() - will return the logical state of the field. A flag will indicate noExpire. * RM_HashGet() - Will get NULL if the field expired. Fields won’t be deleted. * RM_ScanKey() - might return 0 items if all fields got expired. Fields won’t be deleted. * RM_HashSet() - If set, then override expired field. If delete, we can either delete or leave it to active-expiration. XX/NX - logically correct (Verify with tests). Nice to have (not implemented): * RedisModule_CloseKey() - We can local active-expire up-to 100 items. Note: Length will be wrong to modules just like redis (Count expired fields).
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.
Need to be carefull if called by modules since modules API allow to open and close key handler. We don't want to invalidate the handler underneath.
Nice to have (not implemented):
Note:
Length will be wrong to modules just like redis (Count expired fields).