From 1319a7da099fef01a21caa7c15bd98dcddd3acb3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 7 Jun 2018 16:11:45 +0200 Subject: dashboard/app: fix crash save throttling logic bug.LastTime is updated on every crash, even if we don't save it. As the result we did not save recent crashes for popular bugs at all. Fix this by introducing bug.LastSavedCrash. --- dashboard/app/api.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'dashboard/app/api.go') diff --git a/dashboard/app/api.go b/dashboard/app/api.go index 4fdf117d7..f690ca348 100644 --- a/dashboard/app/api.go +++ b/dashboard/app/api.go @@ -519,9 +519,10 @@ func reportCrash(c context.Context, ns string, req *dashapi.Crash) (*Bug, error) } else if len(req.ReproSyz) != 0 { reproLevel = ReproLevelSyz } - saveCrash := bug.NumCrashes < maxCrashes || - now.Sub(bug.LastTime) > time.Hour || - reproLevel != ReproLevelNone + saveCrash := reproLevel != ReproLevelNone || + bug.NumCrashes < maxCrashes || + now.Sub(bug.LastSavedCrash) > time.Hour || + bug.NumCrashes%20 == 0 if saveCrash { // Reporting priority of this crash. // Currently it is computed only from repository ReportingPriority and Arch, @@ -566,6 +567,9 @@ func reportCrash(c context.Context, ns string, req *dashapi.Crash) (*Bug, error) } bug.NumCrashes++ bug.LastTime = now + if saveCrash { + bug.LastSavedCrash = now + } if reproLevel != ReproLevelNone { bug.NumRepro++ } @@ -593,7 +597,7 @@ func reportCrash(c context.Context, ns string, req *dashapi.Crash) (*Bug, error) } func purgeOldCrashes(c context.Context, bug *Bug, bugKey *datastore.Key) { - if bug.NumCrashes <= maxCrashes || bug.NumCrashes%10 != 0 { + if bug.NumCrashes-bug.NumRepro <= maxCrashes || (bug.NumCrashes-1)%10 != 0 { return } var crashes []*Crash -- cgit mrf-deployment