-
Notifications
You must be signed in to change notification settings - Fork 24.4k
HFE - Avoid lazy expire if called by modules + cleanup #13326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HFE - Avoid lazy expire if called by modules + cleanup #13326
Conversation
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
| * 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() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
| if (flags & REDISMODULE_HASH_XX) | ||
| hfeFlags |= HFE_LAZY_AVOID_FIELD_DEL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why even bother deleting the field when using NX? anyway, if it's logically expired we are going to override it with hashTypeSet below
| if (flags & REDISMODULE_HASH_XX) | ||
| hfeFlags |= HFE_LAZY_AVOID_FIELD_DEL; | ||
|
|
||
| int exists = hashTypeExists(key->db, key->value, field->ptr, hfeFlags, NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please note that hashTypeExists/hashTypeGetValue should be called with HFE_LAZY_NO_NOTIFICATION because direct key API doesn't emit notifications (by design)
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).
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).