@@ -68,16 +68,33 @@ sub start_nodes
68
68
world => genstr(3000),
69
69
);
70
70
71
+ my $retries = 100;
71
72
my $timeout_ms = 1000;
72
73
73
- $able -> psql(' postgres' , " select raftable('hello', '$tests {hello}', $timeout_ms );" );
74
- $baker -> psql(' postgres' , " select raftable('and', '$tests {and}', $timeout_ms );" );
75
- $charlie -> psql(' postgres' , " select raftable('goodbye', '$tests {goodbye}', $timeout_ms );" );
74
+ sub trysql {
75
+ my ($noderef , $sql ) = @_ ;
76
+ while ($retries > 0) {
77
+ diag(" try sql: " . substr ($sql , 0, 60));
78
+ my ($rc , $stdout , $stderr ) = $noderef -> psql(' postgres' , $sql );
79
+ if (index ($stderr , " after" ) == -1) {
80
+ return ;
81
+ } else {
82
+ $retries --;
83
+ diag($stderr );
84
+ diag(" psql failed, $retries retries left" );
85
+ }
86
+ }
87
+ BAIL_OUT(' no psql retries left' );
88
+ }
89
+
90
+ trysql($able , " select raftable('hello', '$tests {hello}', $timeout_ms );" );
91
+ trysql($baker , " select raftable('and', '$tests {and}', $timeout_ms );" );
92
+ trysql($charlie , " select raftable('goodbye', '$tests {goodbye}', $timeout_ms );" );
76
93
$baker -> stop;
77
- $able -> psql( ' postgres ' , " select raftable('world', '$tests {world}', $timeout_ms );" );
94
+ trysql( $able , " select raftable('world', '$tests {world}', $timeout_ms );" );
78
95
79
96
$baker -> start;
80
- $baker -> psql( ' postgres ' , " select raftable_sync($timeout_ms );" );
97
+ trysql( $baker , " select raftable_sync($timeout_ms );" );
81
98
while (my ($key , $value ) = each (%tests ))
82
99
{
83
100
my ($rc , $stdout , $stderr ) = $baker -> psql(' postgres' , " select raftable('$key ');" );
0 commit comments