Skip to content

Commit e5a81c4

Browse files
goffrieConvex, Inc.
authored and
Convex, Inc.
committed
Apply jitter to MAX_REPEATABLE_TIMESTAMP_IDLE_FREQUENCY (#37230)
GitOrigin-RevId: 167d0958f25122a422e3f357c4798c68c099e0bc
1 parent f29e984 commit e5a81c4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

crates/common/src/knobs.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,11 @@ pub static TRANSACTION_WARN_READ_SET_INTERVALS: LazyLock<usize> =
340340
LazyLock::new(|| env_config("TRANSACTION_WARN_READ_SET_INTERVALS", 3072));
341341

342342
/// Write max_repeatable_ts if there have been no commits for this duration.
343+
/// The actual period is jittered between 1x and 2x this value.
343344
pub static MAX_REPEATABLE_TIMESTAMP_IDLE_FREQUENCY: LazyLock<Duration> = LazyLock::new(|| {
344345
Duration::from_secs(env_config(
345346
"MAX_REPEATABLE_TIMESTAMP_IDLE_FREQUENCY",
346-
100 * 60,
347+
60 * 60,
347348
))
348349
});
349350

crates/database/src/committer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ use futures::{
8787
use indexing::index_registry::IndexRegistry;
8888
use parking_lot::Mutex;
8989
use prometheus::VMHistogram;
90+
use rand::Rng;
9091
use tokio::sync::{
9192
mpsc::{
9293
self,
@@ -299,7 +300,10 @@ impl<RT: Runtime> Committer<RT> {
299300
let span = committer_span.as_ref().map(|root| Span::enter_with_parent("publish_max_repeatable_ts", root)).unwrap_or_else(Span::noop);
300301
span.set_local_parent();
301302
self.publish_max_repeatable_ts(new_max_repeatable)?;
302-
next_bump_wait = Some(*MAX_REPEATABLE_TIMESTAMP_IDLE_FREQUENCY);
303+
let base_period = *MAX_REPEATABLE_TIMESTAMP_IDLE_FREQUENCY;
304+
next_bump_wait = Some(
305+
self.runtime.rng().random_range(base_period..base_period * 2),
306+
);
303307
let _ = result.send(new_max_repeatable);
304308
drop(timer);
305309
},

0 commit comments

Comments
 (0)