mirror of
https://github.com/livekit/livekit.git
synced 2026-08-28 18:08:17 +00:00
Tweaks to subscription reconcile timeout (#1369)
This commit is contained in:
@@ -18,7 +18,7 @@ require (
|
||||
github.com/jxskiss/base62 v1.1.0
|
||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1
|
||||
github.com/livekit/mediatransportutil v0.0.0-20230130133657-96cfb115473a
|
||||
github.com/livekit/protocol v1.3.3-0.20230131012249-9987dca3a3e7
|
||||
github.com/livekit/protocol v1.3.3-0.20230202034647-c71216774a62
|
||||
github.com/livekit/psrpc v0.2.5
|
||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995
|
||||
github.com/mackerelio/go-osstat v0.2.3
|
||||
|
||||
@@ -234,8 +234,8 @@ github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1 h1:jm09419p0lqTkD
|
||||
github.com/livekit/mageutil v0.0.0-20230125210925-54e8a70427c1/go.mod h1:Rs3MhFwutWhGwmY1VQsygw28z5bWcnEYmS1OG9OxjOQ=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20230130133657-96cfb115473a h1:5UkGQpskXp7HcBmyrCwWtO7ygDWbqtjN09Yva4l/nyE=
|
||||
github.com/livekit/mediatransportutil v0.0.0-20230130133657-96cfb115473a/go.mod h1:1Dlx20JPoIKGP45eo+yuj0HjeE25zmyeX/EWHiPCjFw=
|
||||
github.com/livekit/protocol v1.3.3-0.20230131012249-9987dca3a3e7 h1:PSSiAMb0XmBrhA8xZzpnf9q99Cl64RmCbL7KzmOMb9s=
|
||||
github.com/livekit/protocol v1.3.3-0.20230131012249-9987dca3a3e7/go.mod h1:gwCG03nKlHlC9hTjL4pXQpn783ALhmbyhq65UZxqbb8=
|
||||
github.com/livekit/protocol v1.3.3-0.20230202034647-c71216774a62 h1:wLkf7jiWtA0q+3y192KEkWIdKUrh+cXz/pBwVMZBwq4=
|
||||
github.com/livekit/protocol v1.3.3-0.20230202034647-c71216774a62/go.mod h1:gwCG03nKlHlC9hTjL4pXQpn783ALhmbyhq65UZxqbb8=
|
||||
github.com/livekit/psrpc v0.2.5 h1:+EZS78MGdBZxzCUwinDQ6pOeqPDURisrGtfyyqwUDSI=
|
||||
github.com/livekit/psrpc v0.2.5/go.mod h1:DyphtRRWvcIuCaldYg9VGpwGhu/HiKmNcysgpN6xKrM=
|
||||
github.com/livekit/rtcscore-go v0.0.0-20220815072451-20ee10ae1995 h1:vOaY2qvfLihDyeZtnGGN1Law9wRrw8BMGCr1TygTvMw=
|
||||
|
||||
@@ -35,8 +35,8 @@ import (
|
||||
var (
|
||||
reconcileInterval = 3 * time.Second
|
||||
// amount of time to give up if a track or publisher isn't found
|
||||
// giving this a lot of time because during migrations the user could take a lot of time to resume
|
||||
notFoundTimeout = 20 * time.Second
|
||||
// ensuring this is longer than iceFailedTimeout so we are certain the participant won't return
|
||||
notFoundTimeout = iceFailedTimeout
|
||||
// amount of time to try otherwise before flagging subscription as failed
|
||||
subscriptionTimeout = 20 * time.Second
|
||||
)
|
||||
@@ -381,7 +381,6 @@ func (m *SubscriptionManager) reconcileWorker() {
|
||||
|
||||
func (m *SubscriptionManager) subscribe(s *trackSubscription) error {
|
||||
s.logger.Debugw("executing subscribe")
|
||||
s.startAttempt()
|
||||
|
||||
if !m.params.Participant.CanSubscribe() {
|
||||
return ErrNoSubscribePermission
|
||||
@@ -602,6 +601,14 @@ func (s *trackSubscription) getPublisherIdentity() livekit.ParticipantIdentity {
|
||||
func (s *trackSubscription) setDesired(desired bool) bool {
|
||||
s.lock.Lock()
|
||||
defer s.lock.Unlock()
|
||||
|
||||
if desired {
|
||||
// as long as user explicitly set it to desired
|
||||
// we'll reset the timer so it has sufficient time to reconcile
|
||||
t := time.Now()
|
||||
s.subStartedAt.Store(&t)
|
||||
}
|
||||
|
||||
if s.desired == desired {
|
||||
return false
|
||||
}
|
||||
@@ -611,8 +618,9 @@ func (s *trackSubscription) setDesired(desired bool) bool {
|
||||
s.changeNotifier.RemoveObserver(string(s.subscriberID))
|
||||
s.changeNotifier = nil
|
||||
}
|
||||
|
||||
if desired {
|
||||
// reset attempt
|
||||
// reset attempts
|
||||
s.numAttempts.Store(0)
|
||||
}
|
||||
return true
|
||||
@@ -704,13 +712,6 @@ func (s *trackSubscription) isBound() bool {
|
||||
return s.bound
|
||||
}
|
||||
|
||||
func (s *trackSubscription) startAttempt() {
|
||||
if s.numAttempts.Load() == 0 {
|
||||
t := time.Now()
|
||||
s.subStartedAt.Store(&t)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *trackSubscription) recordAttempt(success bool) {
|
||||
if !success {
|
||||
s.numAttempts.Add(1)
|
||||
|
||||
Reference in New Issue
Block a user