Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set defaults and expose configuration of tchannel timeouts. #2173

Merged
merged 8 commits into from
Feb 26, 2020

Conversation

notbdu
Copy link
Contributor

@notbdu notbdu commented Feb 25, 2020

What this PR does / why we need it:

Set defaults and allow configuration of tchannel options MaxIdleTimeout and IdleCheckInterval to allow cleaning up of idle tchannel connections.

Special notes for your reviewer:

Does this PR introduce a user-facing and/or backwards incompatible change?:

NONE

Does this PR require updating code package or user-facing documentation?:

NONE

@notbdu
Copy link
Contributor Author

notbdu commented Feb 25, 2020

Cleans up idle tchannel connections/goroutines seen in the following profiles.

Screen Shot 2020-02-25 at 3 49 47 PM

Screen Shot 2020-02-25 at 3 50 02 PM

@codecov
Copy link

codecov bot commented Feb 25, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@b4301cd). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2173   +/-   ##
========================================
  Coverage          ?   51.6%           
========================================
  Files             ?     102           
  Lines             ?    9047           
  Branches          ?       0           
========================================
  Hits              ?    4674           
  Misses            ?    4013           
  Partials          ?     360
Flag Coverage Δ
#aggregator 55.5% <0%> (?)
#cluster 100% <0%> (?)
#collector 41.8% <0%> (?)
#m3em 37.3% <0%> (?)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b4301cd...fab5ce2. Read the comment docs.

Copy link
Collaborator

@arnikola arnikola left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a few nits and potential refactor but take it or leave it 👍

@@ -573,3 +576,9 @@ func IsSeedNode(initialCluster []environment.SeedNode, hostID string) bool {

return false
}

// TchannelConfiguration holds tchannel config options.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: TChannelConfiguration

@@ -157,6 +157,9 @@ type DBConfiguration struct {
// Limits contains configuration for limits that can be applied to M3DB for the purposes
// of applying back-pressure or protecting the db nodes.
Limits Limits `yaml:"limits"`

// Tchannel exposes tchannel config options.
Tchannel TchannelConfiguration `yaml:"tchannel"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: TChannel

Would it also be better to make this a pointer to be able to more easily tell when it's not been set and avoid default values? Looks like 0s get filtered out later but may be an option?

@@ -199,6 +199,12 @@ var (
SetJitter(true),
)

// defaultChannelOptions are tchannel channel options defaults.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: defaultChannelOptions are default TChannel options.

Comment on lines 604 to 605
tchannelOpts.MaxIdleTime = cfg.Tchannel.MaxIdleTime
tchannelOpts.IdleCheckInterval = cfg.Tchannel.IdleCheckInterval
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Does this need to check that tchannelOpts.MaxIdleTime >= tchannelOpts.IdleCheckInterval?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check interval can be independent of the max idle time.

Comment on lines +604 to +605
tchannelOpts.MaxIdleTime = cfg.TChannel.MaxIdleTime
tchannelOpts.IdleCheckInterval = cfg.TChannel.IdleCheckInterval
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these need to be greater than 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are checks in the tchannel code already.

func (o *ChannelOptions) validateIdleCheck() error {
        if o.IdleCheckInterval > 0 && o.MaxIdleTime <= 0 {
                return errMaxIdleTimeNotSet
        }

        return nil
}
func (is *idleSweep) start() {
        if is.started || is.idleCheckInterval <= 0 {
                return
        }

        is.ch.log.WithFields(
                LogField{"idleCheckInterval", is.idleCheckInterval},
                LogField{"maxIdleTime", is.maxIdleTime},
        ).Info("Starting idle connections poller.")

        is.started = true
        is.stopCh = make(chan struct{})
        go is.pollerLoop()
}

@@ -158,8 +158,8 @@ type DBConfiguration struct {
// of applying back-pressure or protecting the db nodes.
Limits Limits `yaml:"limits"`

// Tchannel exposes tchannel config options.
Tchannel TchannelConfiguration `yaml:"tchannel"`
// TChannel exposes tchannel config options.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "TChannel" in the comment

@@ -577,8 +577,8 @@ func IsSeedNode(initialCluster []environment.SeedNode, hostID string) bool {
return false
}

// TchannelConfiguration holds tchannel config options.
type TchannelConfiguration struct {
// TChannelConfiguration holds tchannel config options.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "TChannel" in the comment

@notbdu notbdu merged commit 4154ff1 into master Feb 26, 2020
@notbdu notbdu deleted the bdu/tchannel-timeout branch February 26, 2020 19:31
@@ -199,6 +199,12 @@ var (
SetJitter(true),
)

// defaultChannelOptions are default tchannel channel options.
defaultChannelOptions = &tchannel.ChannelOptions{
MaxIdleTime: 5 * time.Minute,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Probably would've opted for 1min max idle time and 1-2 minute idle check interval, just since 1min in this world is a very long time heh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants