diff --git a/Cargo.lock b/Cargo.lock index 0b73013d..0775a37c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -558,7 +558,7 @@ checksum = "b62ddb9cb1ec0a098ad4bbf9344d0713fa193ae1a80af55febcff2627b6a00c1" dependencies = [ "getrandom 0.2.17", "instant", - "rand", + "rand 0.8.5", ] [[package]] @@ -921,7 +921,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" dependencies = [ "generic-array", - "rand_core", + "rand_core 0.6.4", "typenum", ] @@ -1478,7 +1478,7 @@ dependencies = [ "garage_util", "hex", "opentelemetry", - "rand", + "rand 0.9.2", "serde", "tokio", "tokio-util 0.7.18", @@ -1520,7 +1520,7 @@ dependencies = [ "hex", "http 1.4.0", "parse_duration", - "rand", + "rand 0.9.2", "serde", "serde_bytes", "thiserror 2.0.18", @@ -1545,7 +1545,7 @@ dependencies = [ "opentelemetry-contrib", "pin-project", "pretty_env_logger", - "rand", + "rand 0.9.2", "rmp-serde", "serde", "thiserror 2.0.18", @@ -1575,7 +1575,7 @@ dependencies = [ "nix", "opentelemetry", "pnet_datalink", - "rand", + "rand 0.9.2", "reqwest", "schemars", "serde", @@ -1600,7 +1600,7 @@ dependencies = [ "hex", "hexdump", "opentelemetry", - "rand", + "rand 0.9.2", "serde", "serde_bytes", "tokio", @@ -1626,7 +1626,7 @@ dependencies = [ "lazy_static", "mktemp", "opentelemetry", - "rand", + "rand 0.9.2", "rmp-serde", "rustc_version", "serde", @@ -2957,7 +2957,7 @@ dependencies = [ "lazy_static", "percent-encoding", "pin-project", - "rand", + "rand 0.8.5", "thiserror 1.0.69", "tokio", "tokio-stream", @@ -3068,7 +3068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166" dependencies = [ "base64ct", - "rand_core", + "rand_core 0.6.4", "subtle", ] @@ -3182,7 +3182,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c80231409c20246a13fddb31776fb942c38553c51e871f8cbd687a4cfb5843d" dependencies = [ "phf_shared", - "rand", + "rand 0.8.5", ] [[package]] @@ -3494,8 +3494,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", - "rand_chacha", - "rand_core", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", ] [[package]] @@ -3505,7 +3515,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", ] [[package]] @@ -3517,6 +3537,15 @@ dependencies = [ "getrandom 0.2.17", ] +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + [[package]] name = "redox_syscall" version = "0.5.18" @@ -4643,7 +4672,7 @@ dependencies = [ "indexmap 1.9.3", "pin-project", "pin-project-lite", - "rand", + "rand 0.8.5", "slab", "tokio", "tokio-util 0.7.18", @@ -4880,7 +4909,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" dependencies = [ "getrandom 0.2.17", - "rand", + "rand 0.8.5", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index ee06e462..bfbf958b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ parse_duration = "2.1" paste = "1.0" pin-project = "1.0.12" pnet_datalink = "0.34" -rand = "0.8" +rand = "0.9" sha1 = "0.10" sha2 = "0.10" timeago = { version = "0.4", default-features = false } diff --git a/src/block/manager.rs b/src/block/manager.rs index d33110cb..df2c3b2f 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -780,7 +780,7 @@ impl BlockManagerLocked { assert!(to_delete.as_ref() != Some(&tgt_path)); let mut path_tmp = tgt_path.clone(); - let tmp_extension = format!("tmp{}", hex::encode(thread_rng().gen::<[u8; 4]>())); + let tmp_extension = format!("tmp{}", hex::encode(rand::rng().random::<[u8; 4]>())); path_tmp.set_extension(tmp_extension); fs::create_dir_all(&directory).await?; diff --git a/src/block/repair.rs b/src/block/repair.rs index 96ad4bb5..e467229f 100644 --- a/src/block/repair.rs +++ b/src/block/repair.rs @@ -248,7 +248,7 @@ fn randomize_next_scrub_run_time(timestamp: u64) -> u64 { timestamp + SCRUB_INTERVAL .saturating_add(Duration::from_secs( - rand::thread_rng().gen_range(0..3600 * 24 * 10), + rand::rng().random_range(0..3600 * 24 * 10), )) .as_millis() as u64 } diff --git a/src/model/snapshot.rs b/src/model/snapshot.rs index d66e7935..f1ac647d 100644 --- a/src/model/snapshot.rs +++ b/src/model/snapshot.rs @@ -130,7 +130,7 @@ impl Worker for AutoSnapshotWorker { async_snapshot_metadata(&self.garage).await?; - let rand_factor = 1f32 + thread_rng().gen::() / 5f32; + let rand_factor = 1f32 + rand::rng().random::() / 5f32; self.next_snapshot = Instant::now() + self.snapshot_interval.mul_f32(rand_factor); Ok(WorkerState::Idle) diff --git a/src/net/message.rs b/src/net/message.rs index 3126d144..b511cb20 100644 --- a/src/net/message.rs +++ b/src/net/message.rs @@ -78,7 +78,7 @@ impl OrderTag { /// let tag_2 = stream.order(2); /// ``` pub fn stream() -> OrderTagStream { - OrderTagStream(thread_rng().gen()) + OrderTagStream(rand::rng().random()) } } impl OrderTagStream { diff --git a/src/table/sync.rs b/src/table/sync.rs index a4c558bb..5de5f7ae 100644 --- a/src/table/sync.rs +++ b/src/table/sync.rs @@ -510,7 +510,7 @@ impl SyncWorker { partitions.layout_version ); - partitions.partitions.shuffle(&mut thread_rng()); + partitions.partitions.shuffle(&mut rand::rng()); self.todo = Some(partitions); } Err(e) => { diff --git a/src/util/data.rs b/src/util/data.rs index 640e58c9..eaf6e9dc 100644 --- a/src/util/data.rs +++ b/src/util/data.rs @@ -151,7 +151,7 @@ pub fn fasthash(data: &[u8]) -> FastHash { /// Generate a random 32 bytes UUID pub fn gen_uuid() -> Uuid { - rand::thread_rng().gen::<[u8; 32]>().into() + rand::rng().random::<[u8; 32]>().into() } #[cfg(test)] diff --git a/src/util/metrics.rs b/src/util/metrics.rs index b882a886..2760afbf 100644 --- a/src/util/metrics.rs +++ b/src/util/metrics.rs @@ -59,5 +59,5 @@ where // ---- pub fn gen_trace_id() -> TraceId { - rand::thread_rng().gen::<[u8; 16]>().into() + rand::rng().random::<[u8; 16]>().into() }