Skip to content

Commit dd853a7

Browse files
authored
fix(datafusion-distributed): relax ttl map timing constraints (#218)
* Relax timing constraints. * Remove unnecessary changes. Add minor fixes.
1 parent bee1a8f commit dd853a7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/common/ttl_map.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
//! How the Time Wheel Works
44
//!
55
//! Time Buckets: [0] [1] [2] [3] [4] [5] [6] [7] ...
6-
//! Current Time: ^
7-
//! |
8-
//! time % buckets.len()
6+
//! Current Time: ^
7+
//! |
8+
//! (time-1) % buckets.len()
99
//!
1010
//! When inserting key "A" at time=2:
1111
//! - Key "A" goes into bucket[(2-1) % 8] = bucket[1]
@@ -205,7 +205,7 @@ where
205205
self.gc_scheduler_task = Some(vec![gc_task]);
206206
}
207207

208-
/// get_or_default executes the provided closure with a reference to the map entry for the given key.
208+
/// get_or_init executes the provided closure with a reference to the map entry for the given key.
209209
/// If the key does not exist, it inserts a new entry with the default value.
210210
pub fn get_or_init<F>(&self, key: K, init: F) -> V
211211
where
@@ -374,7 +374,7 @@ mod tests {
374374
F: Fn() -> bool,
375375
{
376376
let start = std::time::Instant::now();
377-
while start.elapsed() < timeout {
377+
while start.elapsed() <= timeout {
378378
if assertion() {
379379
return;
380380
}
@@ -384,7 +384,6 @@ mod tests {
384384
}
385385

386386
#[tokio::test(flavor = "multi_thread", worker_threads = 8)]
387-
#[ignore] // the test is flaky, uncomment once flakyness is solved
388387
async fn test_concurrent_gc_and_access() {
389388
let ttl_map = TTLMap::<String, i32>::try_new(TTLMapConfig {
390389
ttl: Duration::from_millis(10),
@@ -421,7 +420,7 @@ mod tests {
421420
handle.await.unwrap();
422421
}
423422

424-
assert_eventually(|| ttl_map.data.is_empty(), Duration::from_millis(20)).await;
423+
assert_eventually(|| ttl_map.data.is_empty(), Duration::from_millis(100)).await;
425424
}
426425

427426
#[tokio::test]

0 commit comments

Comments
 (0)