log.proto: add LeaderInfo; add node_group_leader_info to WriteLogResponse#7
Conversation
WalkthroughAdds a new protobuf message LeaderInfo and augments WriteLogResponse with a node_group_leader_info map field to return leader details per node group. No other messages are modified. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant S as LogService
participant CM as ClusterMeta
rect rgba(227,242,253,0.4)
note over C,S: WriteLog flow with leader info included
C->>S: WriteLog(request)
S->>S: Append entry
S->>CM: Fetch leaders per node group
CM-->>S: node_group_leader_info (map<groupId, LeaderInfo>)
S-->>C: WriteLogResponse{ status, node_group_leader_info }
end
note over C: Client may cache/update leader mapping per group
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
log.proto (2)
265-269: Preferstring ip(IPv4/IPv6) and include a stablenode_idto avoid future breaking change.Across this proto, IPs are modeled as
string(e.g.,ReplayLogRequest.source_ip,AddPeerRequest.ip,GetLogGroupConfigResponse.ip). Usingbytes iphere is inconsistent, complicates cross‑lang handling (endian/length/IPv4 vs IPv6), and will be a breaking change if we switch later. Also, leaders are already identified vianode_idelsewhere (LogLeaderUpdateRequest.node_id,NodeConfig.node_id); relying only on ip/port couples clients to network addressing and makes readdressing harder.Recommend aligning now:
message LeaderInfo { int64 term = 1; - bytes ip = 2; + // String literal to support IPv4 and IPv6; align with existing messages. + string ip = 2; uint32 port = 3; + // Stable identifier; helps when IPs change. + uint32 node_id = 4; }Optional: add a short comment that
portmust be in [1, 65535] and thatipshould be a literal (not hostname).
274-276: Scope and payload: clarify whennode_group_leader_infois populated; consider sending only on redirects.Returning leader info for all node groups on every write may add non‑trivial payload and churn. If the primary consumer is retry logic upon
NotLeaderor redirects, consider populating this map only in those cases, or gate it behind a request flag for clients that want it. At minimum, document the semantics (always present vs best‑effort vs only on redirect), and ensure clients treat it as optional (map may be empty).If you agree to restrict emission to redirects, add a brief comment:
// latest leader info of all node groups - map<uint32, LeaderInfo> node_group_leader_info = 3; + // Populated on redirects or when leadership may have changed; may be empty otherwise. + map<uint32, LeaderInfo> node_group_leader_info = 3;Also confirm the map key is the same “cc node group id” used in
WriteLogRequest.node_termsfor consistency.
Related PR:
eloqdata/tx_service#134
https://github.com/eloqdata/eloq_log_service/pull/18
Summary by CodeRabbit