From 123732e9f41029a91616fb05d565ecffa1321316 Mon Sep 17 00:00:00 2001 From: Jack Rubacha Date: Mon, 6 Jan 2025 21:55:44 -0500 Subject: [PATCH] spruce up comments, fix dependency --- scylla-server/Cargo.toml | 2 +- scylla-server/src/db_handler.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scylla-server/Cargo.toml b/scylla-server/Cargo.toml index 8ae5ddad..7881327c 100644 --- a/scylla-server/Cargo.toml +++ b/scylla-server/Cargo.toml @@ -30,7 +30,7 @@ serde_json = "1.0.128" diesel_migrations = { version = "2.2.0", features = ["postgres"] } rangemap = "1.5.1" axum-macros = "0.5.0" -diesel-async = { version = "0.5.2", features = ["postgres", "bb8", "async-connection-wrapper", "sync-connection-wrapper"] } +diesel-async = { version = "0.5.2", features = ["postgres", "bb8", "async-connection-wrapper", "sync-connection-wrapper", "tokio"] } rustc-hash = "2.1.0" [target.'cfg(not(target_env = "msvc"))'.dependencies] tikv-jemallocator = "0.6" diff --git a/scylla-server/src/db_handler.rs b/scylla-server/src/db_handler.rs index 83060e8d..206bbf95 100644 --- a/scylla-server/src/db_handler.rs +++ b/scylla-server/src/db_handler.rs @@ -188,11 +188,11 @@ impl DbHandler { if !self.data_queue.is_empty() { // set a new max if this batch is larger max_batch_size = usize::max(max_batch_size, self.data_queue.len()); - // mem::take allows us to assign the value of data queue vec::new() while maintaining the memory for data_channel ownership data_channel .send(self.data_queue) .await .expect("Could not comm data to db thread"); + // give a vector a size that hopefully is big enough to fit the next batch self.data_queue = Vec::with_capacity((max_batch_size as f32 * 1.05) as usize); } }