From e452f851631219d2b2daaa3d0c6d3680f1a172d8 Mon Sep 17 00:00:00 2001 From: "Artur M. Wolff" Date: Wed, 11 Aug 2021 16:37:11 +0200 Subject: [PATCH] satellite/metabase: sync batchSizeLimit and ListLimit constants This change syncs batchSizeLimit and ListLimit constants to prevent throwing away results returned while listing with a maximum returns limit. Change-Id: Ie2425542d945cb88653dcc34c079737bb32320d4 --- satellite/metabase/common.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/satellite/metabase/common.go b/satellite/metabase/common.go index 46d957828..d33e2541c 100644 --- a/satellite/metabase/common.go +++ b/satellite/metabase/common.go @@ -28,7 +28,16 @@ const ( // ListLimit is the maximum number of items the client can request for listing. const ListLimit = intLimitRange(1000) -const batchsizeLimit = intLimitRange(1000) +// batchsizeLimit specifies up to how many items fetch from the storage layer at +// a time. +// +// NOTE: A frequent pattern while listing items is to list up to ListLimit items +// and see whether there is more by trying to fetch another one. If the caller +// requests a list of ListLimit size and batchSizeLimit equals ListLimit, we +// would have queried another batch on that check for more items. Most of these +// results, except the first one, would be thrown away by callers. To prevent +// this from happening, we add 1 to batchSizeLimit. +const batchsizeLimit = ListLimit + 1 // BucketPrefix consists of /. type BucketPrefix string