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

kvserver, timeutil: fix some Timer user-after-Stops #61373

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions pkg/kv/kvserver/closedts/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,17 @@ func (p *Provider) runCloser(ctx context.Context) {
// Track whether we've ever been live to avoid logging warnings about not
// being live during node startup.
var everBeenLive bool
var t timeutil.Timer
t := timeutil.NewTimer()
defer t.Stop()
for {
closeFraction := closedts.CloseFraction.Get(&p.cfg.Settings.SV)
targetDuration := float64(closedts.TargetDuration.Get(&p.cfg.Settings.SV))
if targetDuration > 0 {
t.Reset(time.Duration(closeFraction * targetDuration))
} else {
t.Stop() // disable closing when the target duration is non-positive
// Disable closing when the target duration is non-positive.
t.Stop()
t = timeutil.NewTimer()
}
select {
case <-p.cfg.Stopper.ShouldQuiesce():
Expand Down
5 changes: 3 additions & 2 deletions pkg/kv/kvserver/closedts/sidetransport/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ func (s *Sender) Run(ctx context.Context, nodeID roachpb.NodeID) {
s.buf.Close()
}()

var timer timeutil.Timer
timer := timeutil.NewTimer()
defer timer.Stop()
for {
interval := closedts.SideTransportCloseInterval.Get(&s.st.SV)
if interval > 0 {
timer.Reset(closedts.SideTransportCloseInterval.Get(&s.st.SV))
timer.Reset(interval)
} else {
// Disable the side-transport.
timer.Stop()
timer = timeutil.NewTimer()
}
select {
case <-timer.C:
Expand Down