@@ -53,7 +53,7 @@ func (sg *slotGranter) grantKind() grantKind {
53
53
}
54
54
55
55
// tryGet implements granter.
56
- func (sg * slotGranter ) tryGet (count int64 ) bool {
56
+ func (sg * slotGranter ) tryGet (_ burstQualification , count int64 ) bool {
57
57
return sg .coord .tryGet (sg .workKind , count , 0 /*arbitrary*/ )
58
58
}
59
59
@@ -122,7 +122,8 @@ func (sg *slotGranter) continueGrantChain(grantChainID grantChainID) {
122
122
123
123
// requesterHasWaitingRequests implements granterWithLockedCalls.
124
124
func (sg * slotGranter ) requesterHasWaitingRequests () bool {
125
- return sg .requester .hasWaitingRequests ()
125
+ hasWaiting , _ := sg .requester .hasWaitingRequests ()
126
+ return hasWaiting
126
127
}
127
128
128
129
// tryGrantLocked implements granterWithLockedCalls.
@@ -193,7 +194,7 @@ func (tg *tokenGranter) grantKind() grantKind {
193
194
}
194
195
195
196
// tryGet implements granter.
196
- func (tg * tokenGranter ) tryGet (count int64 ) bool {
197
+ func (tg * tokenGranter ) tryGet (_ burstQualification , count int64 ) bool {
197
198
return tg .coord .tryGet (tg .workKind , count , 0 /*arbitrary*/ )
198
199
}
199
200
@@ -239,7 +240,8 @@ func (tg *tokenGranter) continueGrantChain(grantChainID grantChainID) {
239
240
240
241
// requesterHasWaitingRequests implements granterWithLockedCalls.
241
242
func (tg * tokenGranter ) requesterHasWaitingRequests () bool {
242
- return tg .requester .hasWaitingRequests ()
243
+ hasWaiting , _ := tg .requester .hasWaitingRequests ()
244
+ return hasWaiting
243
245
}
244
246
245
247
// tryGrantLocked implements granterWithLockedCalls.
@@ -340,7 +342,7 @@ func (cg *kvStoreTokenChildGranter) grantKind() grantKind {
340
342
}
341
343
342
344
// tryGet implements granter.
343
- func (cg * kvStoreTokenChildGranter ) tryGet (count int64 ) bool {
345
+ func (cg * kvStoreTokenChildGranter ) tryGet (_ burstQualification , count int64 ) bool {
344
346
return cg .parent .tryGet (cg .workType , count )
345
347
}
346
348
@@ -604,14 +606,6 @@ func (sg *kvStoreTokenGranter) subtractTokensLockedForWorkClass(
604
606
}
605
607
}
606
608
607
- // requesterHasWaitingRequests returns whether some requester associated with
608
- // the granter has waiting requests. Used by storeGrantCoordinator.
609
- func (sg * kvStoreTokenGranter ) requesterHasWaitingRequests () bool {
610
- return sg .regularRequester .hasWaitingRequests () ||
611
- sg .elasticRequester .hasWaitingRequests () ||
612
- sg .snapshotRequester .hasWaitingRequests ()
613
- }
614
-
615
609
func (sg * kvStoreTokenGranter ) tryGrant () {
616
610
sg .mu .Lock ()
617
611
defer sg .mu .Unlock ()
@@ -620,13 +614,14 @@ func (sg *kvStoreTokenGranter) tryGrant() {
620
614
621
615
// tryGrantLocked attempts to grant to as many requests as possible.
622
616
func (sg * kvStoreTokenGranter ) tryGrantLocked () {
623
- for sg .requesterHasWaitingRequests () && sg . tryGrantLockedOne () {
617
+ for sg .tryGrantLockedOne () {
624
618
}
625
619
}
626
620
627
621
// tryGrantLocked is used to attempt to grant to waiting requests. Used by
628
622
// storeGrantCoordinator. It successfully grants to at most one waiting
629
- // request.
623
+ // request. If there are no waiting requests, or all waiters reject the grant,
624
+ // it returns false.
630
625
func (sg * kvStoreTokenGranter ) tryGrantLockedOne () bool {
631
626
// NB: We grant work in the following priority order: regular, snapshot
632
627
// ingest, elastic work. Snapshot ingests are a special type of elastic work.
@@ -640,7 +635,8 @@ func (sg *kvStoreTokenGranter) tryGrantLockedOne() bool {
640
635
} else if wt == admissionpb .SnapshotIngestStoreWorkType {
641
636
req = sg .snapshotRequester
642
637
}
643
- if req .hasWaitingRequests () {
638
+ hasWaiting , _ := req .hasWaitingRequests ()
639
+ if hasWaiting {
644
640
res := sg .tryGetLocked (1 , wt )
645
641
if res {
646
642
tookTokenCount := req .granted (noGrantChain )
0 commit comments