1158
}
1159
1160
>
func (s *ContextImpl) renewRangeLocked(isStealing bool) error {
context_impl.go
1161
>
// We must drain all in-flight requests before updating the rangeID.
1162
>
// This is because requests are conditioned on rangeID, if rangeID
1163
>
// is updated before draining them, those requests could fail.
1164
>
// This also means renew rangeID will be the only in-flight request
1165
>
// when it's issued, so it doesn't matter if semaphore is acquired or not
1166
>
// before calling this method.
1167
>
s.taskKeyManager.drainTaskRequests()
1168
>
1169
>
updatedShardInfo := trimShardInfo(s.config, s.clusterMetadata.GetAllClusterInfo(), s.copyShardInfo(s.shardInfo))
1170
>
updatedShardInfo.RangeId++
1171
>
if isStealing {
1172
>
updatedShardInfo.StolenSinceRenew++
1173
>
}
1174
1176
>
defer cancel()
1177
>
1178
>
previousRangeID := s.getRangeIDLocked()
1179
>
err := s.persistenceShardManager.UpdateShard(ctx, &persistence.UpdateShardRequest{
1180
>
ShardInfo: updatedShardInfo,
1181
>
PreviousRangeID: previousRangeID,
1182
>
})
1183
>
if err != nil {
1184
// Failure in updating shard to grab new RangeID
1185
s.contextTaggedLogger.Error("Persistent store operation failure",