Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c26f6e4

Browse files
committed
Prevent raftable from skipping peers during retries.
1 parent 545a044 commit c26f6e4

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

contrib/raftable/raftable.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static struct {
4646
int *leader;
4747
} shared;
4848

49+
static bool try_next_leader = true;
4950
static int leadersock = -1;
5051
static WorkerConfig wcfg;
5152
static char *peerstr;
@@ -78,8 +79,8 @@ static void disconnect_leader(void)
7879
if (leadersock >= 0)
7980
{
8081
close(leadersock);
82+
try_next_leader = true;
8183
}
82-
select_next_peer();
8384
leadersock = -1;
8485
}
8586

@@ -172,7 +173,8 @@ static bool connect_leader(timeout_t *timeout)
172173

173174
HostPort *leaderhp;
174175

175-
if (*shared.leader == NOBODY) select_next_peer();
176+
// if (*shared.leader == NOBODY) select_next_peer();
177+
if (try_next_leader) select_next_peer();
176178

177179
leaderhp = wcfg.peers + *shared.leader;
178180

0 commit comments

Comments
 (0)