Skip to content

Commit

Permalink
MB-48675 Handle memory session without memory quota
Browse files Browse the repository at this point in the history
When memory quota tracking is enabled (there is a memory session) but there
is no quota set (i.e. is zero) don't try calculate remaining quota as
the default CuRL result-cap; instead use the quota-less default.

The quota-less maximum will also be applied.

Change-Id: Ia1a49c9314f80adf3f670a8888f2cb914444cc1a
Reviewed-on: https://review.couchbase.org/c/query/+/184902
Reviewed-by: Sitaram Vemulapalli <sitaram.vemulapalli@couchbase.com>
Tested-by: Donald Haggart <donald.haggart@couchbase.com>
  • Loading branch information
dhaggart committed Jan 12, 2023
1 parent c33e33f commit 2408cef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions expression/func_curl.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2014-Present Couchbase, Inc.
// cOPYRight 2014-Present Couchbase, Inc.
//
// Use of this software is governed by the Business Source License included
// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified
Expand Down Expand Up @@ -251,7 +251,7 @@ func (this *Curl) handleCurl(url string, options map[string]interface{}, allowli
ctx, ok := context.(QuotaContext)
if !ok || !ctx.UseRequestQuota() {
ctx = nil
} else {
} else if ctx.MemoryQuota() != 0 {
availableQuota = uint64(float64(ctx.MemoryQuota()) * (1.0 - ctx.CurrentQuotaUsage()))
if responseSize > availableQuota {
responseSize = availableQuota
Expand Down Expand Up @@ -501,7 +501,7 @@ func (this *Curl) handleCurl(url string, options map[string]interface{}, allowli
}
responseSize = uint64(rs)
// if there is a quota the remaining available memory enforces the upper limit
if ctx == nil && responseSize > _MAX_NO_QUOTA_RESPONSE_SIZE {
if (ctx == nil || ctx.MemoryQuota() == 0) && responseSize > _MAX_NO_QUOTA_RESPONSE_SIZE {
logging.Debuga(func() string {
return fmt.Sprintf("CURL (%v) result-cap %v limited to %v", url, responseSize, _MAX_NO_QUOTA_RESPONSE_SIZE)
})
Expand Down

0 comments on commit 2408cef

Please sign in to comment.