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

fix: bigtable-rotator bug that prevents it from closing channels #390

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
17 changes: 11 additions & 6 deletions go/connection-refresh/btrefresh/bigtable_rotator.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,25 @@ func NewRotatingTable(dialer BtDialer, table string, refresh time.Duration) (*Ro
rt := &RotatingTable{tbl, client, ticker, errors}
go func() {
for range ticker.C {
// Close the old client after waiting a bit
go func() {
oldC := rt.client
time.Sleep(lameduckTime)
oldC.Close()
}()
// save the old client so that we can close it
oldC := rt.client

client, err := dialer()
if err != nil {
errors <- err
continue
}
tbl := client.Open(table)
warmTable(tbl)

rt.client = client
rt.Table = tbl

// Close the old client after waiting a bit
go func() {
time.Sleep(lameduckTime)
oldC.Close()
}()
}
}()
return rt, nil
Expand Down