Skip to content

Commit

Permalink
fix: optimize the mechanism of quota refresh (#18795)
Browse files Browse the repository at this point in the history
Signed-off-by: chlins <chenyuzh@vmware.com>
  • Loading branch information
chlins authored Jun 8, 2023
1 parent 8251fd2 commit c08c7c5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/controller/quota/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ func (c *controller) updateUsageWithRetry(ctx context.Context, reference, refere
return retry.Abort(err)
}

// The PR https://github.com/goharbor/harbor/pull/17392 optimized the logic for post upload blob which use size 0
// for checking quota, this will increase the pressure of optimistic lock, so here return earlier
// if the quota usage has not changed to reduce the probability of optimistic lock.
if types.Equals(used, newUsed) {
return nil
}

q.SetUsed(newUsed)

err = c.quotaMgr.Update(ctx, q)
Expand Down

0 comments on commit c08c7c5

Please sign in to comment.