refactor: use RESPParser for Redis replication - #8211
Conversation
PR Summary by QodoUse RESPParser for Redis replication commands
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
🟠 Medium 1. Header lines grow unbounded
|
🤖 Augment PR SummarySummary: Refactors Redis upstream-replication command parsing around Changes:
🤖 Was this summary useful? React with 👍 or 👎 |
Code Review by Qodo
🔴 High 1. Header lines grow unbounded
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the Redis replication command stream handling to parse incoming commands via facade::RESPParser (hiredis-based) instead of the legacy RedisParser/RespExpr response parsing path, aiming to improve correctness around streaming/buffering.
Changes:
- Switch
Replica::ConsumeRedisStream()to read replication commands usingProtocolClient::ReadRespCommand()and batch/dispatch based on parser-buffered data. - Extend
ProtocolClientwithReadRespCommand(),ResetParser(), andResetCommandParser()to support separate parsing modes for client replies vs replication command streams. - Enhance
facade::RESPParserwith limits plumbing, reset helpers, and “consumed bytes” accounting; add unit tests for streaming state and array limits.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/server/replica.cc | Use ReadRespCommand() for replication stream consumption and batching decisions based on parser buffered input. |
| src/server/protocol_client.h | Add ReadCommandRes, ReadRespCommand(), and split parser reset APIs. |
| src/server/protocol_client.cc | Implement RESPParser-based command reads and introduce command-parser reset with a higher array-length cap. |
| src/server/cluster/outgoing_slot_migration.cc | Update to new ResetParser() signature. |
| src/server/cluster/coordinator.cc | Update to new ResetParser() signature. |
| src/facade/resp_parser.h | Add parser limits, reset API, buffered-input query, and consumed-bytes tracking. |
| src/facade/resp_parser.cc | Implement limits-aware reset and consumed-bytes accounting with bounded error logging. |
| src/facade/resp_parser_test.cc | Add tests for streaming consumption semantics and array length limiting. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dranikpg
left a comment
There was a problem hiding this comment.
What is the goal? Get rid of old parser?
yes. We have 3 parsers; we want to have at least 2 and maybe 1 in the future |
Related to: #8196
Summary: Refactors Redis upstream-replication command parsing around RESPParser.
Changes:
Technical Notes: Redis replication retains its higher array-count allowance; bulk, line, and nesting limits remain documented follow-up work.