Skip to content

Commit 0726ecb

Browse files
committed
multi: roll back change in request page size
This fixes an issue with a new tapd (v0.5.0-rc1) attempting to sync with an old (v0.4.1) universe server. Because we now serve all the root nodes from a cache, we allow a much larger page size when requesting the root nodes. But old universe servers will not yet allow that higher request limit, resulting in the following error: [/universerpc.Universe/AssetLeafKeys]: invalid request limit So we need to use the old limit when _requesting_ pages. And once most of the universe servers have been updated (e.g. v0.5.1), we can then also use the larger limit on requests.
1 parent 4205556 commit 0726ecb

File tree

8 files changed

+20
-13
lines changed

8 files changed

+20
-13
lines changed

cmd/tapcli/universe.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func universeKeys(ctx *cli.Context) error {
321321
ctxc, &unirpc.AssetLeafKeysRequest{
322322
Id: universeID,
323323
Offset: int32(offset),
324-
Limit: universe.MaxPageSize,
324+
Limit: universe.RequestPageSize,
325325
},
326326
)
327327

@@ -336,7 +336,7 @@ func universeKeys(ctx *cli.Context) error {
336336
assetKeys.AssetKeys = append(
337337
assetKeys.AssetKeys, tempKeys.AssetKeys...,
338338
)
339-
offset += universe.MaxPageSize
339+
offset += universe.RequestPageSize
340340
}
341341

342342
printRespJSON(assetKeys)

itest/assertions.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1598,10 +1598,10 @@ func AssertUniverseRootsEqual(a, b *unirpc.AssetRootResponse) bool {
15981598
func AssertUniverseStateEqual(t *testing.T, a, b unirpc.UniverseClient) bool {
15991599
ctxb := context.Background()
16001600

1601-
rootsA, err := assetRoots(ctxb, a, universe.MaxPageSize/100)
1601+
rootsA, err := assetRoots(ctxb, a, universe.RequestPageSize/100)
16021602
require.NoError(t, err)
16031603

1604-
rootsB, err := assetRoots(ctxb, b, universe.MaxPageSize/100)
1604+
rootsB, err := assetRoots(ctxb, b, universe.RequestPageSize/100)
16051605
require.NoError(t, err)
16061606

16071607
return AssertUniverseRootsEqual(rootsA, rootsB)

sample-tapd.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,8 @@
328328
; universe.multiverse-caches.syncer-cache-pre-alloc-size=100000
329329

330330
; The size of the root node page cache for all requests that aren't served by
331-
; the syncer cache. (default: 327680)
332-
; universe.multiverse-caches.root-node-page-cache-size=327680
331+
; the syncer cache. (default: 10240)
332+
; universe.multiverse-caches.root-node-page-cache-size=10240
333333

334334

335335
[address]

tapdb/multiverse.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func (b *MultiverseStore) RootNodes(ctx context.Context,
446446
NumOffset: q.Offset,
447447
NumLimit: func() int32 {
448448
if q.Limit == 0 {
449-
return universe.MaxPageSize
449+
return universe.RequestPageSize
450450
}
451451

452452
return q.Limit
@@ -573,7 +573,7 @@ func (b *MultiverseStore) fillSyncerCache(ctx context.Context) error {
573573
params := sqlc.UniverseRootsParams{
574574
SortDirection: sqlInt16(universe.SortAscending),
575575
NumOffset: 0,
576-
NumLimit: universe.MaxPageSize,
576+
NumLimit: universe.RequestPageSize,
577577
}
578578

579579
allRoots := make(
@@ -586,9 +586,9 @@ func (b *MultiverseStore) fillSyncerCache(ctx context.Context) error {
586586
}
587587

588588
allRoots = append(allRoots, newRoots...)
589-
params.NumOffset += universe.MaxPageSize
589+
params.NumOffset += universe.RequestPageSize
590590

591-
if len(newRoots) < universe.MaxPageSize {
591+
if len(newRoots) < universe.RequestPageSize {
592592
break
593593
}
594594
}

tapdb/multiverse_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func DefaultMultiverseCacheConfig() MultiverseCacheConfig {
6363
LeavesPerUniverse: 50,
6464
SyncerCacheEnabled: false,
6565
SyncerCachePreAllocSize: 100_000,
66-
RootNodePageCacheSize: 20 * universe.MaxPageSize,
66+
RootNodePageCacheSize: 20 * universe.RequestPageSize,
6767
}
6868
}
6969

tapdb/universe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ func mintingKeys(ctx context.Context, dbTx BaseUniverseStore,
723723
NumOffset: q.Offset,
724724
NumLimit: func() int32 {
725725
if q.Limit == 0 {
726-
return universe.MaxPageSize
726+
return universe.RequestPageSize
727727
}
728728

729729
return q.Limit

universe/interface.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ const (
3939
// MaxPageSize is the maximum page size that can be used when querying
4040
// for asset roots and leaves.
4141
MaxPageSize = 16384
42+
43+
// RequestPageSize is the default page size that should be used when
44+
// querying for asset roots and leaves.
45+
//
46+
// TODO(guggero): Bump this to the value of MaxPageSize once the
47+
// universe servers have been updated to v0.5.0-rc1 or later.
48+
RequestPageSize = 512
4249
)
4350

4451
// IdentifierKey is the compact representation of a universe identifier that can

universe/syncer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
const (
19-
defaultPageSize = int32(MaxPageSize)
19+
defaultPageSize = int32(RequestPageSize)
2020
)
2121

2222
var (

0 commit comments

Comments
 (0)