Skip to content

Commit

Permalink
closedts: react faster to config changes
Browse files Browse the repository at this point in the history
This approximately halves the duration of

`make test PKG=./pkg/ccl/changefeedccl TESTS=/sinkless`,

from ~60s to ~30s.

Touches #34455.

Release note: None
  • Loading branch information
tbg committed Feb 26, 2019
1 parent fe23224 commit 966ff29
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/storage/closedts/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ func (p *Provider) runCloser(ctx context.Context) {
ch := p.Notify(p.cfg.NodeID)
defer close(ch)

confCh := make(chan struct{}, 1)
confChanged := func() {
select {
case confCh <- struct{}{}:
default:
}
}
closedts.TargetDuration.SetOnChange(&p.cfg.Settings.SV, confChanged)

var t timeutil.Timer
defer t.Stop()
var lastEpoch ctpb.Epoch
Expand All @@ -134,6 +143,9 @@ func (p *Provider) runCloser(ctx context.Context) {
return
case <-t.C:
t.Read = true
case <-confCh:
// Loop around to use the updated timer.
continue
}

next, epoch, err := p.cfg.Clock(p.cfg.NodeID)
Expand Down

0 comments on commit 966ff29

Please sign in to comment.