[GODRIVER-1647] averageRTTSet is never set Created: 12/Jun/20  Updated: 28/Oct/23  Resolved: 17/Jun/20

Status: Closed
Project: Go Driver
Component/s: Server Discovery and Monitoring
Affects Version/s: None
Fix Version/s: 1.3.5

Type: Bug Priority: Major - P3
Reporter: David Bartley Assignee: Kriti Ravindran (Inactive)
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible

 Description   

There's code in updateAverageRTT that computes a trailing RTT average.  However, that code is gated on averageRTTSet, and that's never set to true.

func (s *Server) updateAverageRTT(delay time.Duration) time.Duration {
    if !s.averageRTTSet {
        s.averageRTT = delay
    } else {
        alpha := 0.2
        s.averageRTT = time.Duration(alpha*float64(delay) + (1-alpha)*float64(s.averageRTT))
    }
    return s.averageRTT
} 

That should probably be:

func (s *Server) updateAverageRTT(delay time.Duration) time.Duration {
    if !s.averageRTTSet {
        s.averageRTT = delay
        s.averageRTTSet = true
    } else {
        alpha := 0.2
        s.averageRTT = time.Duration(alpha*float64(delay) + (1-alpha)*float64(s.averageRTT))
    }
    return s.averageRTT
} 



 Comments   
Comment by Githook User [ 17/Jun/20 ]

Author:

{'name': 'Kriti Ravindran', 'email': 'kriti.ravindran@gmail.com', 'username': 'KritiRav'}

Message: GODRIVER-1647 fix averageRTT calculations (#426)
Branch: release/1.3
https://github.com/mongodb/mongo-go-driver/commit/6ea597f66c2496747ed4d7f9f7251aef294ac167

Comment by Githook User [ 17/Jun/20 ]

Author:

{'name': 'Kriti Ravindran', 'email': 'kriti.ravindran@gmail.com', 'username': 'KritiRav'}

Message: GODRIVER-1647 fix averageRTT calculations (#426)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/fedbabde7aae528417eabeb8573eb2cd1c8f491b

Comment by Kriti Ravindran (Inactive) [ 17/Jun/20 ]

https://github.com/mongodb/mongo-go-driver/pull/426

Generated at Thu Feb 08 08:36:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.