@@ -29,6 +29,7 @@ import (
29
29
"github.com/cockroachdb/cockroach/pkg/roachprod"
30
30
"github.com/cockroachdb/cockroach/pkg/roachprod/install"
31
31
"github.com/cockroachdb/cockroach/pkg/roachprod/logger"
32
+ "github.com/cockroachdb/cockroach/pkg/testutils"
32
33
"github.com/cockroachdb/cockroach/pkg/util"
33
34
"github.com/cockroachdb/cockroach/pkg/util/allstacks"
34
35
"github.com/cockroachdb/cockroach/pkg/util/retry"
@@ -60,7 +61,17 @@ SELECT node_id
60
61
tBeforePing := timeutil .Now ()
61
62
db := c .Conn (ctx , t .L (), node )
62
63
defer db .Close ()
63
- require .NoError (t , db .Ping ())
64
+
65
+ testutils .SucceedsSoon (t , func () error {
66
+ // Having just shut down a node, the sql user table may be in the
67
+ // process of failing over, and if we're unlucky and try to open a new
68
+ // conn here, we can sometimes hit an internal 10s timeout should the
69
+ // failover take longer than usual.
70
+ //
71
+ // See https://github.com/cockroachdb/cockroach/issues/153403#issuecomment-3296381756.
72
+ return db .Ping ()
73
+ })
74
+
64
75
tAfterPing := timeutil .Now ()
65
76
if pingDur := tAfterPing .Sub (tBeforePing ); pingDur > 20 * time .Second {
66
77
t .L ().Printf ("sql connection ready after %.2fs" , pingDur .Seconds ())
0 commit comments