Skip to content

Commit 8fc0195

Browse files
committed
Using 0 for restore and added test for it
Signed-off-by: Hanxi Zhang <hanxizh@amazon.com>
1 parent c155cf8 commit 8fc0195

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

src/cluster.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ void restoreCommand(client *c) {
268268
return;
269269
}
270270

271-
long long now = commandTimeSnapshot();
272271
obj = rdbLoadObject(type, &payload, objectGetVal(key), c->db->id, NULL, RDBFLAGS_NONE, 0);
273272
if (obj == NULL) {
274273
addReplyError(c, "Bad data format");

tests/unit/hashexpire.tcl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4615,4 +4615,31 @@ start_server {tags {"hashexpire skip expired fields"}} {
46154615
assert_equal "" [r HGET myhash f2]
46164616
assert_equal "" [r HGET myhash f3]
46174617
} {} {needs:debug}
4618+
4619+
test {RESTORE loads expired hash fields} {
4620+
r FLUSHALL
4621+
r DEBUG SET-ACTIVE-EXPIRE 0
4622+
4623+
r HSETEX myhash PX 1 FIELDS 3 f1 v1 f2 v2 f3 v3
4624+
r HSET myhash permanent permanent_value
4625+
4626+
set serialized [r DUMP myhash]
4627+
4628+
wait_for_condition 50 100 {
4629+
[lindex [r HTTL myhash FIELDS 1 f1] 0] == -2 &&
4630+
[lindex [r HTTL myhash FIELDS 1 f2] 0] == -2 &&
4631+
[lindex [r HTTL myhash FIELDS 1 f3] 0] == -2
4632+
} else {
4633+
fail "Fields did not expire"
4634+
}
4635+
4636+
r DEL myhash
4637+
r RESTORE myhash 0 $serialized
4638+
4639+
# Verify ALL fields were loaded (including expired ones)
4640+
assert_equal 4 [r HLEN myhash]
4641+
assert_equal "permanent_value" [r HGET myhash permanent]
4642+
4643+
r DEBUG SET-ACTIVE-EXPIRE 1
4644+
} {OK} {needs:debug}
46184645
}

0 commit comments

Comments
 (0)