From c5b5905ed36490bbaaca4081236b7f205afdb68c Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Wed, 9 Feb 2022 00:24:40 +0200 Subject: [PATCH] Remove parking_lot dependency from workspace --- Cargo.lock | 75 ++-------------------------------- pageserver/src/virtual_file.rs | 7 +++- proxy/Cargo.toml | 1 - proxy/src/proxy.rs | 11 +++-- 4 files changed, 16 insertions(+), 78 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dc48c528d9..5bbd555ab1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1319,17 +1319,7 @@ checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", - "parking_lot_core 0.8.5", -] - -[[package]] -name = "parking_lot" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f5ec2493a61ac0506c0f4199f99070cbe83857b0337006a30f3e6719b8ef58" -dependencies = [ - "lock_api", - "parking_lot_core 0.9.1", + "parking_lot_core", ] [[package]] @@ -1346,19 +1336,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "parking_lot_core" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28141e0cc4143da2443301914478dc976a61ffdb3f043058310c70df2fed8954" -dependencies = [ - "cfg-if", - "libc", - "redox_syscall", - "smallvec", - "windows-sys", -] - [[package]] name = "peeking_take_while" version = "0.1.2" @@ -1569,7 +1546,7 @@ dependencies = [ "fnv", "lazy_static", "memchr", - "parking_lot 0.11.2", + "parking_lot", "thiserror", ] @@ -1584,7 +1561,6 @@ dependencies = [ "hyper", "lazy_static", "md5", - "parking_lot 0.12.0", "rand", "reqwest", "routerify", @@ -2258,7 +2234,7 @@ dependencies = [ "fallible-iterator", "futures", "log", - "parking_lot 0.11.2", + "parking_lot", "percent-encoding", "phf", "pin-project-lite", @@ -2280,7 +2256,7 @@ dependencies = [ "fallible-iterator", "futures", "log", - "parking_lot 0.11.2", + "parking_lot", "percent-encoding", "phf", "pin-project-lite", @@ -2717,49 +2693,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3df6e476185f92a12c072be4a189a0210dcdcf512a1891d6dff9edb874deadc6" -dependencies = [ - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5" - -[[package]] -name = "windows_i686_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615" - -[[package]] -name = "windows_i686_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.32.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316" - [[package]] name = "winreg" version = "0.7.0" diff --git a/pageserver/src/virtual_file.rs b/pageserver/src/virtual_file.rs index 82e663b6e8..21b6daa8d9 100644 --- a/pageserver/src/virtual_file.rs +++ b/pageserver/src/virtual_file.rs @@ -332,8 +332,11 @@ impl VirtualFile { // TODO: We could downgrade the locks to read mode before calling // 'func', to allow a little bit more concurrency, but the standard // library RwLock doesn't allow downgrading without releasing the lock, - // and that doesn't seem worth the trouble. (parking_lot RwLock would - // allow it) + // and that doesn't seem worth the trouble. + // + // XXX + // `parking_lot::RwLock` can enable such downgrades, yet its implemenation is fair and + // may deadlock on subsequent read calls, not all code places would benefit from such benaviour let result = STORAGE_IO_TIME .with_label_values(&[op, &self.tenantid, &self.timelineid]) .observe_closure_duration(|| func(&file)); diff --git a/proxy/Cargo.toml b/proxy/Cargo.toml index 110663b1e4..b18647a9c9 100644 --- a/proxy/Cargo.toml +++ b/proxy/Cargo.toml @@ -13,7 +13,6 @@ hex = "0.4.3" hyper = "0.14" # TODO kb reexport this from zenith_utils routerify = "3" -parking_lot = "0.12" serde = "1" serde_json = "1" tokio = { version = "1.11", features = ["macros"] } diff --git a/proxy/src/proxy.rs b/proxy/src/proxy.rs index 1013a5c39e..85f577a6c2 100644 --- a/proxy/src/proxy.rs +++ b/proxy/src/proxy.rs @@ -2,12 +2,12 @@ use crate::cplane_api::{CPlaneApi, DatabaseInfo}; use crate::ProxyState; use anyhow::{anyhow, bail, Context}; use lazy_static::lazy_static; -use parking_lot::Mutex; use rand::prelude::StdRng; use rand::{Rng, SeedableRng}; use std::cell::Cell; use std::collections::HashMap; use std::net::{SocketAddr, TcpStream}; +use std::sync::Mutex; use std::{io, thread}; use tokio_postgres::NoTls; use zenith_metrics::{new_common_metric_name, register_int_counter, IntCounter}; @@ -89,7 +89,7 @@ pub fn thread_main( NUM_CONNECTIONS_CLOSED_COUNTER.inc(); THREAD_CANCEL_KEY_DATA.with(|cell| { if let Some(cancel_key_data) = cell.get() { - CANCEL_MAP.lock().remove(&cancel_key_data); + CANCEL_MAP.lock().unwrap().remove(&cancel_key_data); }; }); })?; @@ -220,7 +220,7 @@ impl ProxyConnection { return Ok(Some((get_param("user")?, get_param("database")?))); } FeStartupPacket::CancelRequest(cancel_key_data) => { - if let Some(cancel_closure) = CANCEL_MAP.lock().get(&cancel_key_data) { + if let Some(cancel_closure) = CANCEL_MAP.lock().unwrap().get(&cancel_key_data) { let runtime = tokio::runtime::Builder::new_current_thread() .enable_all() .build() @@ -333,7 +333,10 @@ async fn connect_to_db( socket_addr, cancel_token: client.cancel_token(), }; - CANCEL_MAP.lock().insert(cancel_key_data, cancel_closure); + CANCEL_MAP + .lock() + .unwrap() + .insert(cancel_key_data, cancel_closure); THREAD_CANCEL_KEY_DATA.with(|cell| { let prev_value = cell.replace(Some(cancel_key_data)); assert!(