fix:SETEX replication does not work(pika-unstable)#3124
fix:SETEX replication does not work(pika-unstable)#3124YuCai18 wants to merge 1 commit intoOpenAtomFoundation:unstablefrom
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe changes update the Changes
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
修复了pika unstable版本中setex在主从上不同步的bug #3117
修改的代码部分
1.命令名称错误:
修改了SetexCmd::ToRedisProtocol()和PsetexCmd::ToRedisProtocol()方法。原代码中,SetexCmd::ToRedisProtocol()方法生成的是pksetexat命令,而不是标准的setex命令。同样,PsetexCmd::ToRedisProtocol()也生成了错误的命令名称。在主从复制过程中,主节点会将命令转换为二进制日志(binlog)发送给从节点,所以从节点无法正确识别和执行这些非标准命令。
2.过期时间计算错误:
原代码中计算过期时间使用了time(nullptr) + ttl_sec_(对于SETEX)和pstd::NowMillis() + ttl_millsec(对于PSETEX)。这意味着主节点计算的是"当前时间+过期秒数"作为绝对过期时间点。当从节点接收到这个命令时,它会直接使用这个绝对时间,而不是重新计算。由于主从之间可能存在时间差或者命令传输延迟,这会导致从节点上的实际过期时间与主节点不一致。
修改后的运行截图
Summary by CodeRabbit