fix: a stalled etcd peer connection ends after 5 retransmissions (keel#167) #182
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Keel-Linux/keel!182
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/etcd-stalled-peer-stream-167"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes keel#167 (the 111 s with no leader). Also fixes the etcd class of keel#177: the learner's
unhealthy cluster, the etcd-auth deadlines, the vip f/g promotes and the postgres b drop all came after a cut, while a peer stream still waited for a retransmission.Cause
Reproduced in the netns harness at 250 ms ±25 ms with 2% loss: 3 members, 12 cuts of the leader for 40 s. A peer connection that lost its segments in a cut doubles its retransmission timeout, up to the kernel's 120 s. etcd goes on writing raft's messages to it and sees no error (the send queue grew from 4347 to 8343 bytes, backoff 7, RTO 58 s, 80 s after the heal). A survivor's votes wait in that connection, so the election waits for the next retransmission. One cut had no leader for the whole 40 s. This matches the real nodes: the witness got none of 9054's messages, then a burst of old ones after the heal.
The etcd tuning that keel renders cannot end such a connection:
--raft-read-timeoutand--raft-write-timeout(5 s): the write goes into the kernel's buffer and does not fail; the reader side had already closed, and its FIN was lost in the cut;Fix
keel writes
/etc/sysctl.d/90-keel-etcd.confwithnet.ipv4.tcp_retries2 = 5, and apply sets it live withsysctl -w(no restart: the kernel reads it at each retransmission). The kernel ends a stalled connection after about 14 s, and etcd dials again. The value is per network namespace, for IPv4 and IPv6. Its effect on the other TCP users of the node and the false-kill risk (6 losses of one segment in a row at 2%: once in 10^10) are in the docstring ofkeel/mesh/etcdconf.py,docs/mesh.mdand the handbook amendment of 0050 (Keel-Linux/handbook#84).Test (written first)
tests/etcd_netns.pysamples each second the TCP backoff of every etcd peer connection.tests/test_etcd_netns.pynow fails when:The netns harnesses of etcd and of the VIP set keel's sysctl file in each namespace, as a node does.
12 leader cuts, without and with the setting: new leader 9 to 28 s and one cut with none in 40 s, against 8 to 13 s; members back 24 to 61 s after the heal, against 8 to 16 s. Evidence:
evidence/2026-10-15-etcd-stalled-peer-stream.md.Unit tests:
tests/test_mesh_etcdconf.py,tests/test_system_etcd.py(the file, the live set, nothing under--root). The unit suite without the netns suites: 3833 passed, 4 skipped.keel 0.23.31. Not released: releases wait for the real-node matrix (BR3-THIN is offline).
30ba87ac758b65d1dc45