Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis 持久化 AOF 未过期字段恢复时过期时间重置问题 #63

Open
isayme opened this issue Oct 21, 2021 · 0 comments
Open

Comments

@isayme
Copy link
Owner

isayme commented Oct 21, 2021

Redis AOF 核心原理已协议文本方式记录数据库写入命令。

假如以下场景:

  1. 设置 key A 过期时间为 30秒;
  2. 在第 15 秒 redis 服务异常关闭,此时 key A 还有 15 秒过期;
  3. 在 5 分钟后 redis 服务重新启动并从 aof 文件恢复数据;

由于 AOF 恢复的机制是回放命令,导致恢复后的 key A 的过期时间重置为相对当前时间之后的 30 秒。
如果 redis 服务并没有异常关闭,key A 理应早已过期。

另,RDB 恢复不会有如上类似的问题。

@isayme isayme changed the title Redis 持久化 AOF 未过期字段恢复时过期时间重置问题。 Redis 持久化 AOF 未过期字段恢复时过期时间重置问题 Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant