Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-19.2: util/mon: don't crash when shrinking by too much #51015

Merged
merged 1 commit into from Jul 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/util/mon/bytes_usage.go
Expand Up @@ -565,8 +565,10 @@ func (b *BoundAccount) Grow(ctx context.Context, x int64) error {
// Shrink releases part of the cumulated allocations by the specified size.
func (b *BoundAccount) Shrink(ctx context.Context, delta int64) {
if b.used < delta {
panic(fmt.Sprintf("%s: no bytes in account to release, current %d, free %d",
b.mon.name, b.used, delta))
log.ReportOrPanic(ctx, &b.mon.settings.SV,
"%s: no bytes in account to release, current %d, free %d",
b.mon.name, b.used, delta)
delta = b.used
}
b.used -= delta
b.reserved += delta
Expand Down