@@ -40,9 +40,7 @@ import (
4040
4141const (
4242 // Messages that provide detail about why a snapshot was rejected.
43- snapshotStoreTooFullMsg = "store almost out of disk space"
44- snapshotApplySemBusyMsg = "store busy applying snapshots"
45- storeDrainingMsg = "store is draining"
43+ storeDrainingMsg = "store is draining"
4644
4745 // IntersectingSnapshotMsg is part of the error message returned from
4846 // canAcceptSnapshotLocked and is exposed here so testing can rely on it.
@@ -500,38 +498,23 @@ func (kvSS *kvBatchSnapshotStrategy) Close(ctx context.Context) {
500498}
501499
502500// reserveSnapshot throttles incoming snapshots. The returned closure is used
503- // to cleanup the reservation and release its resources. A nil cleanup function
504- // and a non-empty rejectionMessage indicates the reservation was declined.
501+ // to cleanup the reservation and release its resources.
505502func (s * Store ) reserveSnapshot (
506503 ctx context.Context , header * SnapshotRequest_Header ,
507- ) (_cleanup func (), _rejectionMsg string , _err error ) {
504+ ) (_cleanup func (), _err error ) {
508505 tBegin := timeutil .Now ()
509- if header .RangeSize == 0 {
510- // Empty snapshots are exempt from rate limits because they're so cheap to
511- // apply. This vastly speeds up rebalancing any empty ranges created by a
512- // RESTORE or manual SPLIT AT, since it prevents these empty snapshots from
513- // getting stuck behind large snapshots managed by the replicate queue.
514- } else if header .CanDecline {
515- storeDesc , ok := s .cfg .StorePool .getStoreDescriptor (s .StoreID ())
516- if ok && (! maxCapacityCheck (storeDesc ) || header .RangeSize > storeDesc .Capacity .Available ) {
517- return nil , snapshotStoreTooFullMsg , nil
518- }
519- select {
520- case s .snapshotApplySem <- struct {}{}:
521- case <- ctx .Done ():
522- return nil , "" , ctx .Err ()
523- case <- s .stopper .ShouldQuiesce ():
524- return nil , "" , errors .Errorf ("stopped" )
525- default :
526- return nil , snapshotApplySemBusyMsg , nil
527- }
528- } else {
506+
507+ // Empty snapshots are exempt from rate limits because they're so cheap to
508+ // apply. This vastly speeds up rebalancing any empty ranges created by a
509+ // RESTORE or manual SPLIT AT, since it prevents these empty snapshots from
510+ // getting stuck behind large snapshots managed by the replicate queue.
511+ if header .RangeSize != 0 {
529512 select {
530513 case s .snapshotApplySem <- struct {}{}:
531514 case <- ctx .Done ():
532- return nil , "" , ctx .Err ()
515+ return nil , ctx .Err ()
533516 case <- s .stopper .ShouldQuiesce ():
534- return nil , "" , errors .Errorf ("stopped" )
517+ return nil , errors .Errorf ("stopped" )
535518 }
536519 }
537520
@@ -560,7 +543,7 @@ func (s *Store) reserveSnapshot(
560543 if header .RangeSize != 0 {
561544 <- s .snapshotApplySem
562545 }
563- }, "" , nil
546+ }, nil
564547}
565548
566549// canAcceptSnapshotLocked returns (_, nil) if the snapshot can be applied to
@@ -716,16 +699,10 @@ func (s *Store) receiveSnapshot(
716699 header .Type , storeID , header .State .Desc .Replicas ())
717700 }
718701
719- cleanup , rejectionMsg , err := s .reserveSnapshot (ctx , header )
702+ cleanup , err := s .reserveSnapshot (ctx , header )
720703 if err != nil {
721704 return err
722705 }
723- if cleanup == nil {
724- return stream .Send (& SnapshotResponse {
725- Status : SnapshotResponse_DECLINED ,
726- Message : rejectionMsg ,
727- })
728- }
729706 defer cleanup ()
730707
731708 // The comment on ReplicaPlaceholder motivates and documents
@@ -995,7 +972,6 @@ func SendEmptySnapshot(
995972 State : state ,
996973 RaftMessageRequest : req ,
997974 RangeSize : ms .Total (),
998- CanDecline : false ,
999975 Priority : SnapshotRequest_RECOVERY ,
1000976 Strategy : SnapshotRequest_KV_BATCH ,
1001977 Type : SnapshotRequest_VIA_SNAPSHOT_QUEUE ,
@@ -1056,20 +1032,6 @@ func sendSnapshot(
10561032 return err
10571033 }
10581034 switch resp .Status {
1059- case SnapshotResponse_DECLINED :
1060- if header .CanDecline {
1061- declinedMsg := "reservation rejected"
1062- if len (resp .Message ) > 0 {
1063- declinedMsg = resp .Message
1064- }
1065- err := & benignError {errors .Errorf ("%s: remote declined %s: %s" , to , snap , declinedMsg )}
1066- storePool .throttle (throttleDeclined , err .Error (), to .StoreID )
1067- return err
1068- }
1069- err := errors .Errorf ("%s: programming error: remote declined required %s: %s" ,
1070- to , snap , resp .Message )
1071- storePool .throttle (throttleFailed , err .Error (), to .StoreID )
1072- return err
10731035 case SnapshotResponse_ERROR :
10741036 storePool .throttle (throttleFailed , resp .Message , to .StoreID )
10751037 return errors .Errorf ("%s: remote couldn't accept %s with error: %s" ,
0 commit comments