Describe the bug

When executing HINCRBYFLOAT on a field of HFE, the expiration time of that field is removed on the replica, even though the master retains it. This leads to an inconsistency between master and replica.

To reproduce

  • master
127.0.0.1:6379> hset hash f1 1
(integer) 1
127.0.0.1:6379> hexpire hash 200 fields 1 f1
1) (integer) 1
127.0.0.1:6379> hincrbyfloat hash f1 1
"2"
127.0.0.1:6379> HTTL hash fields 1 f1
1) (integer) 187
  • replica
127.0.0.1:6380> httl hash fields 1 f1  <== after hexpire
1) (integer) 197
127.0.0.1:6380> httl hash fields 1 f1 <== after hincrbyfloat
1) (integer) -1

Expected behavior

Field expiration metadata should be preserved on the replica after HINCRBYFLOAT

Additional information

the root cause is that we rewrite HINCRBYFLOAT to HSET after executing HINCRBYFLOAT

https://github.com/redis/redis/blob/f6f16746e1d4bc51960158d9a896e1aa0a2c7dbd/src/t_hash.c#L2565-L2572

maybe we can use HSETEX ... KEEPTTL, but HSETEX is introduced from 8.0, the bug should be introduced from 7.4

Comment From: ShooterIT

could you please have a look @moticless