From 5c552f6bfbc18afc7ef1fd65153864dce4ced9db Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 11 Nov 2024 09:47:39 +0700 Subject: [PATCH 1/2] fix underflow when clock is 0 --- serf/snapshot.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/serf/snapshot.go b/serf/snapshot.go index 28bb668e6..3606cef25 100644 --- a/serf/snapshot.go +++ b/serf/snapshot.go @@ -347,9 +347,9 @@ func (s *Snapshotter) processMemberEvent(e MemberEvent) { // clock value. This is done after member events but should also be done // periodically due to race conditions with join and leave intents func (s *Snapshotter) updateClock() { - lastSeen := s.clock.Time() - 1 - if lastSeen > s.lastClock { - s.lastClock = lastSeen + current := s.clock.Time() - 1 + if current > s.lastClock+1 { + s.lastClock = current - 1 s.tryAppend(fmt.Sprintf("clock: %d\n", s.lastClock)) } } From ef8aeba19eabeb15409cda23927b41d3899700f9 Mon Sep 17 00:00:00 2001 From: phuoc Date: Mon, 11 Nov 2024 09:54:12 +0700 Subject: [PATCH 2/2] current time means current! --- serf/snapshot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serf/snapshot.go b/serf/snapshot.go index 3606cef25..2676bd0dd 100644 --- a/serf/snapshot.go +++ b/serf/snapshot.go @@ -347,7 +347,7 @@ func (s *Snapshotter) processMemberEvent(e MemberEvent) { // clock value. This is done after member events but should also be done // periodically due to race conditions with join and leave intents func (s *Snapshotter) updateClock() { - current := s.clock.Time() - 1 + current := s.clock.Time() if current > s.lastClock+1 { s.lastClock = current - 1 s.tryAppend(fmt.Sprintf("clock: %d\n", s.lastClock))