Skip to content

Commit c11418c

Browse files
authored
Revert "Do not unban replicas if a primary is available" (#850)
Revert "Do not unban replicas if a primary is available (#843)" This reverts commit cdcfa99.
1 parent c9544bd commit c11418c

File tree

5 files changed

+2
-26
lines changed

5 files changed

+2
-26
lines changed

Diff for: CONFIG.md

-10
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ default: 60 # seconds
130130

131131
How long to ban a server if it fails a health check (seconds).
132132

133-
### unban_replicas_when_all_banned
134-
```
135-
path: general.unban_replicas_when_all_banned
136-
default: true
137-
```
138-
139-
Whether or not we should unban all replicas when they are all banned. This is set
140-
to true by default to prevent disconnection when we have replicas with a false positive
141-
health check.
142-
143133
### log_client_connections
144134
```
145135
path: general.log_client_connections

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ The setting will persist until it's changed again or the client disconnects.
175175
By default, all queries are routed to the first available server; `default_role` setting controls this behavior.
176176

177177
### Failover
178-
All servers are checked with a `;` (very fast) query before being given to a client. Additionally, the server health is monitored with every client query that it processes. If the server is not reachable, it will be banned and cannot serve any more transactions for the duration of the ban. The queries are routed to the remaining servers. If all servers become banned, the behavior is controlled by the configuration parameter `unban_replicas_when_all_banned`. If it is set to true (the default), the ban list is cleared: this is a safety precaution against false positives, if it is set to false, no replicas will be available until they become healthy. The primary can never be banned.
178+
All servers are checked with a `;` (very fast) query before being given to a client. Additionally, the server health is monitored with every client query that it processes. If the server is not reachable, it will be banned and cannot serve any more transactions for the duration of the ban. The queries are routed to the remaining servers. If all servers become banned, the ban list is cleared: this is a safety precaution against false positives. The primary can never be banned.
179179

180180
The ban time can be changed with `ban_time`. The default is 60 seconds.
181181

Diff for: src/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,6 @@ pub struct General {
315315
#[serde(default = "General::default_ban_time")]
316316
pub ban_time: i64,
317317

318-
#[serde(default)] // True
319-
pub unban_replicas_when_all_banned: bool,
320-
321318
#[serde(default = "General::default_idle_client_in_transaction_timeout")]
322319
pub idle_client_in_transaction_timeout: u64,
323320

@@ -463,7 +460,6 @@ impl Default for General {
463460
healthcheck_timeout: Self::default_healthcheck_timeout(),
464461
healthcheck_delay: Self::default_healthcheck_delay(),
465462
ban_time: Self::default_ban_time(),
466-
unban_replicas_when_all_banned: true,
467463
idle_client_in_transaction_timeout: Self::default_idle_client_in_transaction_timeout(),
468464
server_lifetime: Self::default_server_lifetime(),
469465
server_round_robin: Self::default_server_round_robin(),

Diff for: src/pool.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ pub struct PoolSettings {
189189
// Ban time
190190
pub ban_time: i64,
191191

192-
// Should we automatically unban replicas when all are banned?
193-
pub unban_replicas_when_all_banned: bool,
194-
195192
// Regex for searching for the sharding key in SQL statements
196193
pub sharding_key_regex: Option<Regex>,
197194

@@ -231,7 +228,6 @@ impl Default for PoolSettings {
231228
healthcheck_delay: General::default_healthcheck_delay(),
232229
healthcheck_timeout: General::default_healthcheck_timeout(),
233230
ban_time: General::default_ban_time(),
234-
unban_replicas_when_all_banned: true,
235231
sharding_key_regex: None,
236232
shard_id_regex: None,
237233
regex_search_limit: 1000,
@@ -545,9 +541,6 @@ impl ConnectionPool {
545541
healthcheck_delay: config.general.healthcheck_delay,
546542
healthcheck_timeout: config.general.healthcheck_timeout,
547543
ban_time: config.general.ban_time,
548-
unban_replicas_when_all_banned: config
549-
.general
550-
.unban_replicas_when_all_banned,
551544
sharding_key_regex: pool_config
552545
.sharding_key_regex
553546
.clone()
@@ -953,9 +946,8 @@ impl ConnectionPool {
953946
let read_guard = self.banlist.read();
954947
let all_replicas_banned = read_guard[address.shard].len() == replicas_available;
955948
drop(read_guard);
956-
let unban_replicas_when_all_banned = self.settings.clone().unban_replicas_when_all_banned;
957949

958-
if all_replicas_banned && unban_replicas_when_all_banned {
950+
if all_replicas_banned {
959951
let mut write_guard = self.banlist.write();
960952
warn!("Unbanning all replicas.");
961953
write_guard[address.shard].clear();

Diff for: src/query_router.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,6 @@ mod test {
14691469
healthcheck_delay: PoolSettings::default().healthcheck_delay,
14701470
healthcheck_timeout: PoolSettings::default().healthcheck_timeout,
14711471
ban_time: PoolSettings::default().ban_time,
1472-
unban_replicas_when_all_banned: true,
14731472
sharding_key_regex: None,
14741473
shard_id_regex: None,
14751474
default_shard: crate::config::DefaultShard::Shard(0),
@@ -1548,7 +1547,6 @@ mod test {
15481547
healthcheck_delay: PoolSettings::default().healthcheck_delay,
15491548
healthcheck_timeout: PoolSettings::default().healthcheck_timeout,
15501549
ban_time: PoolSettings::default().ban_time,
1551-
unban_replicas_when_all_banned: true,
15521550
sharding_key_regex: Some(Regex::new(r"/\* sharding_key: (\d+) \*/").unwrap()),
15531551
shard_id_regex: Some(Regex::new(r"/\* shard_id: (\d+) \*/").unwrap()),
15541552
default_shard: crate::config::DefaultShard::Shard(0),

0 commit comments

Comments
 (0)