From 84a383638bb3bcdfa87b51b4c41f55d0f2a06aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Niewrza=C5=82?= Date: Thu, 9 Sep 2021 15:15:19 +0200 Subject: [PATCH] satellite/metabase: increase maximum batch size for loop Current default is equal to hardcoded maximum of batch size for loop listing. With this change we will bump maximum batch size but current default won't change. We will be able to increase it later without need for source code change. Change-Id: I2744a87be28af4157f58ede73455682f61733bc1 --- satellite/metabase/loop.go | 12 +++--------- satellite/metabase/segmentloop/service.go | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/satellite/metabase/loop.go b/satellite/metabase/loop.go index 1c977236b..a2d58d3c4 100644 --- a/satellite/metabase/loop.go +++ b/satellite/metabase/loop.go @@ -14,7 +14,7 @@ import ( "storj.io/private/tagsql" ) -const loopIteratorBatchSizeLimit = 2500 +const loopIteratorBatchSizeLimit = intLimitRange(5000) // IterateLoopObjects contains arguments necessary for listing objects in metabase. type IterateLoopObjects struct { @@ -72,10 +72,7 @@ func (db *DB) IterateLoopObjects(ctx context.Context, opts IterateLoopObjects, f asOfSystemInterval: opts.AsOfSystemInterval, } - // ensure batch size is reasonable - if it.batchSize <= 0 || it.batchSize > loopIteratorBatchSizeLimit { - it.batchSize = loopIteratorBatchSizeLimit - } + loopIteratorBatchSizeLimit.Ensure(&it.batchSize) it.curRows, err = it.doNextQuery(ctx) if err != nil { @@ -256,10 +253,7 @@ func (db *DB) IterateLoopSegments(ctx context.Context, opts IterateLoopSegments, cursor: loopSegmentIteratorCursor{}, } - // ensure batch size is reasonable - if it.batchSize <= 0 || it.batchSize > loopIteratorBatchSizeLimit { - it.batchSize = loopIteratorBatchSizeLimit - } + loopIteratorBatchSizeLimit.Ensure(&it.batchSize) it.curRows, err = it.doNextQuery(ctx) if err != nil { diff --git a/satellite/metabase/segmentloop/service.go b/satellite/metabase/segmentloop/service.go index 388121315..c62c92bd4 100644 --- a/satellite/metabase/segmentloop/service.go +++ b/satellite/metabase/segmentloop/service.go @@ -18,7 +18,7 @@ import ( "storj.io/storj/satellite/metabase" ) -const batchsizeLimit = 2500 +const batchsizeLimit = 5000 var ( mon = monkit.Package()