accounting/tally: if delta < 0, delta = 0
if redis crashed in the middle of tally we could have a situation where we erroneously subtract from a project total. Currently, `latest` should never be less than `initial` Change-Id: Ibb5ab724ac0ad4d684f7954fad7a9e061104b7df
This commit is contained in:
parent
33d696b096
commit
f10b22eae9
@ -132,6 +132,9 @@ func (service *Service) Tally(ctx context.Context) (err error) {
|
||||
|
||||
for projectID, latest := range latestLiveTotals {
|
||||
delta := latest - initialLiveTotals[projectID]
|
||||
if delta < 0 {
|
||||
delta = 0
|
||||
}
|
||||
err = service.liveAccounting.AddProjectStorageUsage(ctx, projectID, -latest+tallyProjectTotals[projectID]+(delta/2))
|
||||
if err != nil {
|
||||
return Error.Wrap(err)
|
||||
|
Loading…
Reference in New Issue
Block a user