-
Notifications
You must be signed in to change notification settings - Fork 0
Code Review Bench PR #14224 - Fix HINCRBYFLOAT removes field expiration on replica #9
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -2556,23 +2556,24 @@ void hincrbyfloatCommand(client *c) { | |||||||
| char buf[MAX_LONG_DOUBLE_CHARS]; | ||||||||
| int len = ld2string(buf,sizeof(buf),value,LD_STR_HUMAN); | ||||||||
| new = sdsnewlen(buf,len); | ||||||||
| hashTypeSet(c->db, o,c->argv[2]->ptr,new,HASH_SET_TAKE_VALUE | HASH_SET_KEEP_TTL); | ||||||||
| hashTypeSet(c->db, o,c->argv[2]->ptr,new,HASH_SET_TAKE_VALUE); | ||||||||
| addReplyBulkCBuffer(c,buf,len); | ||||||||
| signalModifiedKey(c,c->db,c->argv[1]); | ||||||||
| notifyKeyspaceEvent(NOTIFY_HASH,"hincrbyfloat",c->argv[1],c->db->id); | ||||||||
| server.dirty++; | ||||||||
|
|
||||||||
| /* Always replicate HINCRBYFLOAT as an HSET command with the final value | ||||||||
| /* Always replicate HINCRBYFLOAT as an HSETEX command with the final value | ||||||||
| * in order to make sure that differences in float precision or formatting | ||||||||
| * will not create differences in replicas or after an AOF restart. */ | ||||||||
| * will not create differences in replicas or after an AOF restart. | ||||||||
| * The KEEPTTL flag is used to make sure the field TTL is preserved. */ | ||||||||
| robj *newobj; | ||||||||
| newobj = createRawStringObject(buf,len); | ||||||||
| rewriteClientCommandArgument(c,0,shared.hset); | ||||||||
| rewriteClientCommandArgument(c,3,newobj); | ||||||||
| rewriteClientCommandVector(c, 6, shared.hsetex, c->argv[1], shared.keepttl, | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 Bug: Argument count mismatch: argc=6 but 7 args passedThe The correct HSETEX syntax is Was this helpful? React with 👍 / 👎
Suggested change
|
||||||||
| shared.fields, shared.integers[1], c->argv[2], newobj); | ||||||||
| decrRefCount(newobj); | ||||||||
| } | ||||||||
|
|
||||||||
| static GetFieldRes addHashFieldToReply(client *c, kvobj *o, sds field, int hfeFlags) { | ||||||||
| GetFieldRes addHashFieldToReply(client *c, kvobj *o, sds field, int hfeFlags) { | ||||||||
| if (o == NULL) { | ||||||||
| addReplyNull(c); | ||||||||
| return GETF_NOT_FOUND; | ||||||||
|
|
||||||||
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.
🚨 Bug: Removing HASH_SET_KEEP_TTL clears field TTL on master
The
HASH_SET_KEEP_TTLflag was removed from the localhashTypeSetcall on line 2559. Without this flag,hashTypeSetwill actively clear the field's TTL on the master:HASH_LP_NO_TTLhfieldPersist(o, oldField)which removes the TTLThis means
HINCRBYFLOATon the master now destroys the field's TTL, which is the opposite of the intended behavior. The replication fix (HSETEX with KEEPTTL) only affects replicas — the master still needsHASH_SET_KEEP_TTLto preserve the field's TTL locally.Note that
hincrbyCommand(line 2506) correctly retainsHASH_SET_KEEP_TTL, so this removal appears to be an error. The flag should be restored.Was this helpful? React with 👍 / 👎