-
Notifications
You must be signed in to change notification settings - Fork 0
Fix HINCRBYFLOAT removes field expiration on replica #31
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
base: coderabbit_full_base_fix_hincrbyfloat_removes_field_expiration_on_replica_pr9
Are you sure you want to change the base?
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, | ||||||||||||||||||||||||||||||||||||||||
| shared.fields, shared.integers[1], c->argv[2], newobj); | ||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+2565
to
+2572
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. Fix argc mismatch in Line 2571 passes 7 arguments but sets 🔧 Proposed fix- rewriteClientCommandVector(c, 6, shared.hsetex, c->argv[1], shared.keepttl,
+ rewriteClientCommandVector(c, 7, shared.hsetex, c->argv[1], shared.keepttl,
shared.fields, shared.integers[1], c->argv[2], newobj);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||
| 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.
Preserve TTL on primary when updating HINCRBYFLOAT.
Line 2559 drops
HASH_SET_KEEP_TTL, which removes existing field TTLs on the primary and can diverge from replicas now that KEEPTTL is used in replication. This also contradicts the existing “HINCRBYFLOAT - preserve expiration time of the field” behavior.🔧 Proposed fix
🤖 Prompt for AI Agents