diff --git a/src/t_hash.c b/src/t_hash.c index e258eb71f..5ea456597 100644 --- a/src/t_hash.c +++ b/src/t_hash.c @@ -1022,7 +1022,6 @@ int hashTypeSet(redisDb *db, kvobj *o, sds field, sds value, int flags) { if (newExpireAt != EB_EXPIRE_TIME_INVALID) { dict *d = o->ptr; htMetadataEx *dictExpireMeta = htGetMetadataEx(d); - serverAssert(dictExpireMeta->expireMeta.trash == 0); ebAdd(&dictExpireMeta->hfe, &hashFieldExpireBucketsType, newEntry, newExpireAt); } @@ -3478,9 +3477,6 @@ static void hfieldPersist(robj *hashObj, Entry *entry) { dict *d = hashObj->ptr; htMetadataEx *dictExpireMeta = htGetMetadataEx(d); - /* If field has valid expiry then dict must have valid metadata as well */ - serverAssert(dictExpireMeta->expireMeta.trash == 0); - /* Remove field from private HFE DS */ ebRemove(&dictExpireMeta->hfe, &hashFieldExpireBucketsType, entry); diff --git a/tests/unit/type/hash-field-expire.tcl b/tests/unit/type/hash-field-expire.tcl index e1ba72019..402a9ad72 100644 --- a/tests/unit/type/hash-field-expire.tcl +++ b/tests/unit/type/hash-field-expire.tcl @@ -1277,6 +1277,24 @@ start_server {tags {"external:skip needs:debug"}} { assert_range [r hpttl myhash FIELDS 1 f3] 4500 5000 } + test "HSETEX EX - field appears twice in FIELDS list with EX is allowed ($type)" { + # The EX condition passes, so all fields must be set, and the last value wins. + r del myhash + r hset myhash f1 v1 + r hsetex myhash EX 100 FIELDS 2 f1 new1 f1 new2 + # Last value wins (same as plain HSET behavior with duplicate fields) + assert_equal "new2" [r hget myhash f1] + assert_range [r httl myhash FIELDS 1 f1] 80 100 + } + + test "HSETEX FNX - field appears twice in FIELDS list with EX is allowed ($type)" { + # The FNX condition passes, so all fields must be set, and the last value wins. + r del myhash + r hsetex myhash FNX EX 100 FIELDS 2 f1 new1 f1 new2 + assert_equal "new2" [r hget myhash f1] + assert_range [r httl myhash FIELDS 1 f1] 80 100 + } + test "HSETEX - Test 'EX' flag ($type)" { r del myhash r hset myhash f1 v1 f2 v2