Skip to content

Dead redis_protocol::write_command_readonly passes wrong length (16 vs 18 bytes) #461

Description

@fcostaoliveira

Summary

protocol.cpp:322 redis_protocol::write_command_readonly() passes 16 to evbuffer_add for the literal *1\r\n$8\r\nREADONLY\r\n which is 18 bytes. Truncates trailing \r\n — server would hang waiting for command terminator.

Why not currently triggered

The READONLY setup-ladder in shard_connection.cpp:923-924 uses a raw bufferevent_write(...) with sizeof(READONLY_CMD)-1 (correct 18-byte length). The vtable method is unused. grep of the tree returns no other callers.

Why fix it anyway

If anyone later refactors the ladder or rearm_readonly to use the vtable method for uniformity with AUTH/SELECT/HELLO/CLUSTER_SLOTS, the bug surfaces silently as a server hang.

Suggested fix

Change the 16 to sizeof("*1\r\n$8\r\nREADONLY\r\n")-1 (= 18), or just delete the dead method since the actual call site bypasses it.

Surfaced during PR #456 round-16 deep review (R1 opus).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions