Skip to content

Commit

Permalink
more WIP fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber committed May 30, 2024
1 parent d325dce commit 780abdf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion go/pools/smartconnpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ func (pool *ConnPool[C]) put(conn *Pooled[C]) {

if conn == nil {
var err error
conn, err = pool.connNew(context.Background())
// TODO: Do we really want to wait for up to a second here?
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
conn, err = pool.connNew(ctx)
if err != nil {
pool.closedConn()
return
Expand Down
6 changes: 5 additions & 1 deletion go/vt/vttablet/tabletserver/repltracker/poller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package repltracker

import (
"context"
"sync"
"time"

Expand Down Expand Up @@ -45,7 +46,10 @@ func (p *poller) Status() (time.Duration, error) {
p.mu.Lock()
defer p.mu.Unlock()

status, err := p.mysqld.ReplicationStatus()
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()

status, err := p.mysqld.ReplicationStatusWithContext(ctx)
if err != nil {
return 0, err
}
Expand Down
3 changes: 2 additions & 1 deletion go/vt/vttablet/tabletserver/repltracker/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,15 @@ func (r *heartbeatReader) Status() (time.Duration, error) {
func (r *heartbeatReader) readHeartbeat() {
defer r.env.LogError()

ctx, cancel := context.WithDeadline(context.Background(), r.now().Add(r.interval))
ctx, cancel := context.WithTimeout(context.Background(), r.interval)
defer cancel()

res, err := r.fetchMostRecentHeartbeat(ctx)
if err != nil {
r.recordError(vterrors.Wrap(err, "failed to read most recent heartbeat"))
return
}

ts, err := parseHeartbeatResult(res)
if err != nil {
r.recordError(vterrors.Wrap(err, "failed to parse heartbeat result"))
Expand Down

0 comments on commit 780abdf

Please sign in to comment.