From 900a25993fa59c98ad1f737fcfb14436543d1938 Mon Sep 17 00:00:00 2001 From: Alexander Zavorotynskiy Date: Mon, 31 Jul 2023 15:48:25 +0400 Subject: [PATCH] fix(backend): removed mini ddos of sessions with negative duration --- backend/cmd/ender/main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/cmd/ender/main.go b/backend/cmd/ender/main.go index 5f84e0983..2cf0f50b3 100644 --- a/backend/cmd/ender/main.go +++ b/backend/cmd/ender/main.go @@ -94,6 +94,7 @@ func main() { case <-tick: failedSessionEnds := make(map[uint64]uint64) duplicatedSessionEnds := make(map[uint64]uint64) + negativeDuration := make(map[uint64]uint64) // Find ended sessions and send notification to other services sessionEndGenerator.HandleEndedSessions(func(sessionID uint64, timestamp uint64) bool { @@ -109,6 +110,10 @@ func main() { failedSessionEnds[sessionID] = timestamp return true } + if strings.Contains(err.Error(), "is less than zero for uint64") { + negativeDuration[sessionID] = timestamp + return true + } log.Printf("can't save sessionEnd to database, sessID: %d, err: %s", sessionID, err) return false } @@ -138,6 +143,9 @@ func main() { if len(duplicatedSessionEnds) > 0 { log.Println("session end duplicates:", duplicatedSessionEnds) } + if len(negativeDuration) > 0 { + log.Println("sessions with negative duration:", negativeDuration) + } producer.Flush(cfg.ProducerTimeout) if err := consumer.CommitBack(intervals.EVENTS_BACK_COMMIT_GAP); err != nil { log.Printf("can't commit messages with offset: %s", err)