Skip to content

Commit 90662e7

Browse files
author
Renato Costa
committed
roachtest: set max lifetime for connections in local runs
This change fixes an issue observed when running roachtests that restart nodes locally. This was primarily observed on M1s, but we apply the same change regardless of platform for consistency. Epic: none Release note: None
1 parent 0f31d50 commit 90662e7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pkg/cmd/roachtest/cluster.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,22 @@ func (c *clusterImpl) ConnE(
26772677
if err != nil {
26782678
return nil, err
26792679
}
2680+
2681+
// When running roachtest locally, we set a max connection lifetime
2682+
// to avoid errors like the following:
2683+
//
2684+
// `read tcp 127.0.0.1:63742 -> 127.0.0.1:26257: read: connection reset by peer`
2685+
//
2686+
// The pq issue below seems related. This was only observed in local
2687+
// runs so the lifetime is only applied in that context intentionally;
2688+
// for cloud runs, we use the connection pool's default behaviour.
2689+
//
2690+
// https://github.com/lib/pq/issues/835
2691+
if c.spec.Cloud == spec.Local {
2692+
localConnLifetime := 10 * time.Second
2693+
db.SetConnMaxLifetime(localConnLifetime)
2694+
}
2695+
26802696
return db, nil
26812697
}
26822698

0 commit comments

Comments
 (0)