add test case and comments for active expiry in the writeable replica (#11789)

This test case is to cover a edge scenario: when a writable replica enabled AOF
at the same time, active expiry keys which was created in writable replicas should
propagate to the AOF file, and some versions might crash (fixed by #11615).
For details, please refer to #11778
This commit is contained in:
judeng 2023-02-20 16:23:25 +08:00 committed by GitHub
parent 3ac835777c
commit 40659c3424
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -385,7 +385,8 @@ void expireSlaveKeys(void) {
activeExpireCycleTryExpire(server.db+dbid,expire,start))
{
expired = 1;
/* DELs aren't propagated, but modules may want their hooks. */
/* Propagate the DEL (writable replicas do not propagate anything to other replicas,
* but they might propagate to AOF) and trigger module hooks. */
postExecutionUnitOperations();
}

View File

@ -571,6 +571,23 @@ start_server {tags {"expire"}} {
assert_equal [$primary pexpiretime $key] [$replica pexpiretime $key]
}
}
test {expired key which is created in writeable replicas should be deleted by active expiry} {
$primary flushall
$replica config set replica-read-only no
foreach {yes_or_no} {yes no} {
$replica config set appendonly $yes_or_no
waitForBgrewriteaof $replica
set prev_expired [s expired_keys]
$replica set foo bar PX 1
wait_for_condition 100 10 {
[s expired_keys] eq $prev_expired + 1
} else {
fail "key not expired"
}
assert_equal {} [$replica get foo]
}
}
}
test {SET command will remove expire} {