summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorny0312 <49037844+ny0312@users.noreply.github.com>2021-06-12 22:42:20 -0700
committerGitHub <noreply@github.com>2021-06-13 08:42:20 +0300
commitfb140a1bff5a4fc3082e362f4b57030625193115 (patch)
tree47999dd06b379c64f4b34e3c9f714614c2cdc4ab
parent63da66bb63ddd77bf448bd8f9b3e4790172a3f26 (diff)
downloadredis-fb140a1bff5a4fc3082e362f4b57030625193115.tar.gz
Fix flaky test case for absolute TTL replication (#9069)
The root cause is that one test (`5 keys in, 5 keys out`) is leaking a volatile key that can expire while another later test(`All TTL in commands are propagated as absolute timestamp in replication stream`) is running. Such leaked expiration injects an unexpected `DEL` command into the replication command during the later test, causing it to fail. The fixes are two fold: 1. Plug the leak in the first test. 2. Add FLUSHALL to the later test, to avoid future interference from other tests.
-rw-r--r--src/expire.c2
-rw-r--r--tests/unit/expire.tcl6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/expire.c b/src/expire.c
index 8996ae57e..91798b527 100644
--- a/src/expire.c
+++ b/src/expire.c
@@ -570,7 +570,7 @@ void pexpireatCommand(client *c) {
expireGenericCommand(c,0,UNIT_MILLISECONDS);
}
-/* Implements TTL, PTTL and EXPIRETIME */
+/* Implements TTL, PTTL, EXPIRETIME and PEXPIRETIME */
void ttlGenericCommand(client *c, int output_ms, int output_abs) {
long long expire, ttl = -1;
diff --git a/tests/unit/expire.tcl b/tests/unit/expire.tcl
index 5293d90fa..d3c9d63c5 100644
--- a/tests/unit/expire.tcl
+++ b/tests/unit/expire.tcl
@@ -221,8 +221,9 @@ start_server {tags {"expire"}} {
r set e c
r set s c
r set foo b
- lsort [r keys *]
- } {a e foo s t}
+ assert_equal [lsort [r keys *]] {a e foo s t}
+ r del a ; # Do not leak volatile keys to other tests
+ }
test {EXPIRE with empty string as TTL should report an error} {
r set foo bar
@@ -433,6 +434,7 @@ start_server {tags {"expire"}} {
# stream, which is as absolute timestamps.
# See: https://github.com/redis/redis/issues/8433
+ r flushall ; # Clean up keyspace to avoid interference by keys from other tests
set repl [attach_to_replication_stream]
# SET commands
r set foo1 bar ex 200