-
Notifications
You must be signed in to change notification settings - Fork 0
Fix HINCRBYFLOAT removes field expiration on replica #22
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_combined_20260121_augment_sentry_coderabbit_1_base_fix_hincrbyfloat_removes_field_expiration_on_replica_pr106
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
+2571
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. Critical: Wrong argc value causes value to be missing from replicated command. The
The expected With 🐛 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.
Critical: Missing
HASH_SET_KEEP_TTLcauses TTL removal on master.The
HASH_SET_KEEP_TTLflag has been removed from thehashTypeSetcall. Looking at thehashTypeSetimplementation (lines 959-964 and 988-991), when this flag is NOT set and the field has a TTL, the TTL is removed.This creates master/replica inconsistency:
HASH_SET_KEEP_TTL)HSETEX ... KEEPTTL)Additionally, the existing test at lines 851-857 expects TTL to be preserved on master:
test {HINCRBYFLOAT - preserve expiration time of the field} { ... assert_range [r HPTTL h1 FIELDS 1 f1] 1 20 }Compare with
HINCRBYat line 2506 which correctly usesHASH_SET_TAKE_VALUE | HASH_SET_KEEP_TTL.🐛 Proposed fix
🤖 Prompt for AI Agents