fix(peer): re-arm outbound TcpPrioClient after heartbeat RX timeout

When a heartbeat RX timeout fires on a peer link, heartbeatTick() calls
m_con.disconnect() to tear the connection down.  TcpPrioClient handles
that by transitioning its state machine to StateDisconnected, which has
no retry timer — only an explicit connect() advances it.  And manual
disconnect() does not emit the disconnected signal, so the listener-
based onDisconnected() path that *would* have retried is also bypassed.
Net effect: the outbound dial parks forever, and only a process restart
recovers the link.  This affected real-world TWIN deployments where
both peers' outbounds time out simultaneously and neither comes back.

Re-call connect() right after the timeout-driven disconnect at the three
sites: TwinLink::heartbeatTick (twin OB), TrunkLink::heartbeatTick (non-
paired OB), and TrunkLink::heartbeatTick (paired per-host OB).  Inbound
side does not need re-arming — it recovers when the partner's freshly-
re-armed outbound dials back in.

Add test_12_twin_heartbeat_recovery: docker pauses ref2 (cgroup freezer
keeps TCP alive while userspace stalls), waits for ref1's RX timeout
log, unpauses, and asserts /status.twin.outbound_connected flips back
to true.  Distinct from test_06 (SIGKILL → passive disconnect → already
worked).  Verified the test fails on the unpatched binary at Step 5
with the exact "StateDisconnected lockup regression" assertion.
This commit is contained in:
Audric committed 2026-05-06 20:00:53 +02:00
1 parent 2e1095e3da
commit 658a1b153f
3 files changed
+100

No files matched your search

+6
View File
@@ -1272,6 +1272,9 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
geulog::error("trunk", "[", m_section, "] Paired outbound #", i,
" heartbeat timeout");
m_ob_cons[i]->disconnect();
// TcpPrioClient parks in StateDisconnected after a manual disconnect
// and won't auto-retry; re-arm explicitly so the link recovers.
m_ob_cons[i]->connect();
}
else if (m_ob_states[i].hb_rx_cnt <= 5)
{
@@ -1338,6 +1341,9 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{
geulog::error("trunk", "[", m_section, "] Outbound heartbeat timeout");
m_con.disconnect();
// TcpPrioClient parks in StateDisconnected after a manual disconnect
// and won't auto-retry; re-arm explicitly so the link recovers.
m_con.connect();
}
else if (m_ob_hb_rx_cnt <= 5)
{
+3
View File
@@ -750,6 +750,9 @@ void TwinLink::heartbeatTick(Async::Timer* /*t*/)
{
geulog::warn("twin", "TWIN: outbound RX timeout, disconnecting");
m_con.disconnect();
// TcpPrioClient parks in StateDisconnected after a manual disconnect
// and won't auto-retry; re-arm explicitly so the link recovers.
m_con.connect();
m_ob_hb_rx_cnt = 0;
}
}