When a peer reconnects, heartbeats to another idle peer may be delayed.
The remote peer may then close the connection due to inactivity.
All peers in a section share one sync task. While processing each peer,
the task's deadline is overwritten, even when an earlier peer needs to
wake up sooner.
Keep the earliest deadline across all peers, both when updates are pending
and when peers are idle.
The faulty assignments were introduced by commit
045e0d4b3 ("BUG/MINOR: peers: Really close the sessions with no heartbeat.")
during 2.0 development.
Thank you to @snh for having reported this issue in GH #3536.
This fix should be backported to all maintained stable branches.
* come back to send heartbeat messages or to reconnect.
*/
TRACE_DEVEL("wakeup peer session to send update", PEERS_EV_SESS_WAKE, NULL, peer);
- task->expire = tick_first(peer->reconnect, peer->heartbeat);
+ task->expire = tick_first(task->expire, tick_first(peer->reconnect, peer->heartbeat));
appctx_wakeup(peer->appctx);
break;
}
TRACE_DEVEL("wakeup peer session to send heartbeat message", PEERS_EV_SESS_WAKE, NULL, peer);
appctx_wakeup(peer->appctx);
}
- task->expire = tick_first(peer->reconnect, peer->heartbeat);
+ task->expire = tick_first(task->expire, tick_first(peer->reconnect, peer->heartbeat));
}
}
/* else do nothing */