Redis uses lazy-expiration to delete stale keys, that is when a command touches a expired key, it should delete the key and propagate the deletion at first.
But there are many bugs in past, present and maybe future... time is a too flexible variable.
- delete expired keys in EVAL may cause data inconsistency after replication, discussed in #1525, fixed
- time's change breaks command's atomicity and cause server crash in some commands like
SPOPandBRPOPLPUSH, discussed in #6152, fixed in #6615 by introduce time snapshot - wrapping expire-dels in a transaction to propagate but leads to CROSSSLOT replication in
SCANandRANDOMKEY, introduced in #9890 and fixed in #11788 - wrapping write command and expire-dels in a transaction to propagate, introduced in #9890, not fixed
SCANinMULTI/EXECtriggers expire-dels and expire-dels wrapped in a transaction to propagate, leads to CROSSSLOT replication, not fixed- Modules + notifications may cause unwanted propagation #10014 not fixed
- maybe some other cases around scripts and module