fix(failover): free the leader lock soon after the leader's host dies

A leader whose host died without closing its connection kept the
advisory lock for about two hours of OS keepalive defaults, and no other
frontend could probe. The lock session now sets short TCP keepalives and
tcp_user_timeout, so the server drops it within about 30 seconds.

Shutdown now closes the lock for good, so a tick that runs after it
cannot take the lock back.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto committed 2026-09-27 07:42:20 +00:00
1 parent b5792e4d17
commit e59fb854ee
4 files changed
+175 -31

No files matched your search

+3 -1
View File
@@ -87,6 +87,8 @@ func (a *Application) stopFailoverDistributed() {
}
}
if a.failoverLock != nil {
a.failoverLock.Release()
// Close, not Release: Run may still be ticking and would take the
// lock straight back.
a.failoverLock.Close()
}
}