Skip to content

Commit 760db30

Browse files
author
Tim Bruijnzeels
authored
Do not resync CAs with repo on startup if there are too many #818
1 parent 388b931 commit 760db30

File tree

3 files changed

+28
-14
lines changed

3 files changed

+28
-14
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ In addition to this we added a few other quick fixes in this release:
7272
- Decrease CA update frequency and use jitter to spread load #802
7373
- Accept missing tag in RFC8181 Error Response #809
7474
- Improve efficiency of connection status tracking #811
75+
- Do not resync CAs with repo on startup if there are too many #818
7576

7677

7778
The full list of changes can be found here:

src/constants.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pub const CA_REFRESH_SECONDS_MIN: i64 = 3600;
7272
pub const CA_REFRESH_SECONDS_MAX: i64 = 3 * 24 * 3600; // 3 days
7373
pub const CA_SUSPEND_MIN_HOURS: i64 = 48; // at least 2 days
7474
pub const SCHEDULER_REQUEUE_DELAY_SECONDS: i64 = 300;
75+
pub const SCHEDULER_RESYNC_REPO_CAS_THRESHOLD: usize = 5;
7576
pub const SCHEDULER_USE_JITTER_CAS_THRESHOLD: usize = 50;
7677
pub const SCHEDULER_USE_JITTER_CAS_PARENTS_THRESHOLD: usize = 5;
7778
pub const SCHEDULER_INTERVAL_REPUBLISH_MINS: i64 = 5;

src/daemon/scheduler.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ use crate::{
1212
bgp::BgpAnalyser,
1313
KrillResult,
1414
},
15-
constants::{SCHEDULER_INTERVAL_RENEW_MINS, SCHEDULER_INTERVAL_REPUBLISH_MINS, SCHEDULER_USE_JITTER_CAS_THRESHOLD},
15+
constants::{
16+
SCHEDULER_INTERVAL_RENEW_MINS, SCHEDULER_INTERVAL_REPUBLISH_MINS, SCHEDULER_RESYNC_REPO_CAS_THRESHOLD,
17+
SCHEDULER_USE_JITTER_CAS_THRESHOLD,
18+
},
1619
daemon::{
1720
ca::CaManager,
1821
config::Config,
@@ -146,20 +149,28 @@ impl Scheduler {
146149

147150
debug!("Adding tasks at start up");
148151

149-
let use_jitter = cas.len() >= SCHEDULER_USE_JITTER_CAS_THRESHOLD;
152+
let too_many_cas_resync_parent = cas.len() >= SCHEDULER_USE_JITTER_CAS_THRESHOLD;
153+
let too_many_cas_resync_repo = cas.len() >= SCHEDULER_RESYNC_REPO_CAS_THRESHOLD;
150154

151155
for summary in cas {
152156
let ca = self.ca_manager.get_ca(summary.handle()).await?;
153157

154-
debug!("Adding tasks for CA {}, using jitter: {}", ca.handle(), use_jitter);
158+
let too_many_parents = ca.nr_parents() >= self.config.ca_refresh_parents_batch_size;
155159

156160
// Plan a regular sync for each parent. Spread these out if there
157161
// are too many CAs or parents for a CA. In cases where there are only
158162
// a handful of CAs/parents, this 'ca_refresh_start_up' will be 'now'.
159163
//
160164
// Note: users can change the priority to 'now' by using the 'bulk' functions.
161-
let too_many_parents = ca.nr_parents() >= self.config.ca_refresh_parents_batch_size;
162-
if !use_jitter && too_many_parents {
165+
let use_parent_sync_jitter = too_many_cas_resync_parent || too_many_parents;
166+
167+
debug!(
168+
"Adding tasks for CA {}, using jitter: {}",
169+
ca.handle(),
170+
use_parent_sync_jitter
171+
);
172+
173+
if !too_many_cas_resync_parent && too_many_parents {
163174
debug!(
164175
"Will force jitter for sync between CA {} and parents. Nr of parents ({}) exceeds batch size ({})",
165176
ca.handle(),
@@ -172,18 +183,19 @@ impl Scheduler {
172183
self.tasks.sync_parent(
173184
ca.handle().clone(),
174185
parent.clone(),
175-
self.config.ca_refresh_start_up(use_jitter || too_many_parents),
186+
self.config.ca_refresh_start_up(use_parent_sync_jitter),
176187
);
177188
}
178189

179-
// Plan a sync with the repo. In case we only have a handful of CAs
180-
// then the result is that the sync is scheduled asap. Otherwise
181-
// spread the load.
182-
// Note: if circumstances dictate a sync before it's planned, e.g.
183-
// because ROAs are changed, then it will be rescheduled accordingly.
184-
// Note: users can override using the 'bulk' functions.
185-
self.tasks
186-
.sync_repo(ca.handle().clone(), self.config.ca_refresh_start_up(use_jitter));
190+
// Plan a sync with the repo. But only in case we only have a handful
191+
// of CAs.
192+
//
193+
// Note: if circumstances dictate a sync e.g. because ROAs are changed,
194+
// then it will be scheduled accordingly. Furthermore, users can use the
195+
// 'bulk' function to explicitly force schedule a sync.
196+
if !too_many_cas_resync_repo {
197+
self.tasks.sync_repo(ca.handle().clone(), now());
198+
}
187199

188200
// If suspension is enabled then plan a task for it. Since this is
189201
// a cheap no-op in most cases, we do not need jitter. If we do not

0 commit comments

Comments
 (0)