1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use std::time::Duration;
/// Configuration for the engine behaviour
///
/// The defaults are optimal so please only modify these if you know
/// deliberately why you are modifying them.
#[derive(Clone, Copy, Debug)]
pub struct EngineOptions {
/// Interval for refreshing node membership information
pub node_membership_refresh_interval: Duration,
/// Interval for checking node membership status
pub node_membership_check_interval: Duration,
/// Interval for cleaning up inactive nodes from the cluster
pub node_membership_cleanup_interval: Duration,
/// Interval for garbage collecting expired changefeed data
pub changefeed_gc_interval: Duration,
/// Interval for running the index compaction process
///
/// The index compaction thread runs at this interval to process indexes
/// that have been marked for compaction. Compaction helps optimize index
/// performance, particularly for full-text indexes, by consolidating
/// changes and removing unnecessary data.
///
/// Default: 5 seconds
pub index_compaction_interval: Duration,
/// Interval for processing queued async events.
///
/// Default: 5 seconds
pub event_processing_interval: Duration,
/// Interval between TiKV MVCC garbage-collection passes.
///
/// Each pass calls `cleanup_locks` followed by `update_safepoint`,
/// allowing TiKV to reclaim space taken by superseded MVCC versions.
/// Mirrors TiDB's default of 10 minutes. Set to `Duration::ZERO` to
/// disable scheduling (the value is also gated by
/// `SURREAL_TIKV_GC_ENABLED`).
///
/// Only the TiKV backend acts on this interval; other backends ignore
/// the task entirely.
///
/// Default: 10 minutes
pub tikv_gc_interval: Duration,
/// How far behind the current TSO a TiKV GC safepoint is allowed to
/// sit. The actual safepoint passed to `gc()` is
/// `current_timestamp - lifetime`.
///
/// Default: 10 minutes
pub tikv_gc_lifetime: Duration,
/// Interval between standalone TiKV lock-cleanup passes.
///
/// Faster cadence than the full GC pass because stale locks block
/// readers immediately, while version GC can wait.
///
/// Default: 60 seconds
pub tikv_lock_cleanup_interval: Duration,
}
impl Default for EngineOptions {
fn default() -> Self {
Self {
node_membership_refresh_interval: Duration::from_secs(3),
node_membership_check_interval: Duration::from_secs(15),
node_membership_cleanup_interval: Duration::from_secs(300),
changefeed_gc_interval: Duration::from_secs(30),
index_compaction_interval: Duration::from_secs(5),
event_processing_interval: Duration::from_secs(5),
tikv_gc_interval: Duration::from_secs(600),
tikv_gc_lifetime: Duration::from_secs(600),
tikv_lock_cleanup_interval: Duration::from_secs(60),
}
}
}
impl EngineOptions {
pub fn with_node_membership_refresh_interval(mut self, interval: Duration) -> Self {
self.node_membership_refresh_interval = interval;
self
}
pub fn with_node_membership_check_interval(mut self, interval: Duration) -> Self {
self.node_membership_check_interval = interval;
self
}
pub fn with_node_membership_cleanup_interval(mut self, interval: Duration) -> Self {
self.node_membership_cleanup_interval = interval;
self
}
pub fn with_changefeed_gc_interval(mut self, interval: Duration) -> Self {
self.changefeed_gc_interval = interval;
self
}
pub fn with_index_compaction_interval(mut self, interval: Duration) -> Self {
self.index_compaction_interval = interval;
self
}
pub fn with_event_processing_interval(mut self, interval: Duration) -> Self {
self.event_processing_interval = interval;
self
}
pub fn with_tikv_gc_interval(mut self, interval: Duration) -> Self {
self.tikv_gc_interval = interval;
self
}
pub fn with_tikv_gc_lifetime(mut self, lifetime: Duration) -> Self {
self.tikv_gc_lifetime = lifetime;
self
}
pub fn with_tikv_lock_cleanup_interval(mut self, interval: Duration) -> Self {
self.tikv_lock_cleanup_interval = interval;
self
}
}