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 ++++++++---- dashboard/app/entities.go | 33 +++++++++++++++++---------------- 2 files changed, 25 insertions(+), 20 deletions(-) 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 diff --git a/dashboard/app/entities.go b/dashboard/app/entities.go index dbff67753..0f4b604e7 100644 --- a/dashboard/app/entities.go +++ b/dashboard/app/entities.go @@ -65,22 +65,23 @@ type Build struct { } type Bug struct { - Namespace string - Seq int64 // sequences of the bug with the same title - Title string - Status int - DupOf string - NumCrashes int64 - NumRepro int64 - ReproLevel dashapi.ReproLevel - HasReport bool - FirstTime time.Time - LastTime time.Time - Closed time.Time - Reporting []BugReporting - Commits []string - HappenedOn []string `datastore:",noindex"` // list of managers - PatchedOn []string `datastore:",noindex"` // list of managers + Namespace string + Seq int64 // sequences of the bug with the same title + Title string + Status int + DupOf string + NumCrashes int64 + NumRepro int64 + ReproLevel dashapi.ReproLevel + HasReport bool + FirstTime time.Time + LastTime time.Time + LastSavedCrash time.Time + Closed time.Time + Reporting []BugReporting + Commits []string + HappenedOn []string `datastore:",noindex"` // list of managers + PatchedOn []string `datastore:",noindex"` // list of managers } type BugReporting struct { -- cgit mrf-deployment