diff --git a/Cargo.lock b/Cargo.lock index ad29fa4634..5441b0f4b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3737,6 +3737,7 @@ dependencies = [ "sysinfo", "tenant_size_model", "thiserror", + "thread_local", "tikv-jemallocator", "tokio", "tokio-epoll-uring", diff --git a/pageserver/Cargo.toml b/pageserver/Cargo.toml index 2531abc7a1..e5981460fd 100644 --- a/pageserver/Cargo.toml +++ b/pageserver/Cargo.toml @@ -55,6 +55,7 @@ serde_with.workspace = true sysinfo.workspace = true tokio-tar.workspace = true thiserror.workspace = true +thread_local = { version = "1.1" } tikv-jemallocator.workspace = true tokio = { workspace = true, features = ["process", "sync", "fs", "rt", "io-util", "time"] } tokio-epoll-uring.workspace = true diff --git a/pageserver/src/virtual_file/io_engine/tokio_epoll_uring_ext.rs b/pageserver/src/virtual_file/io_engine/tokio_epoll_uring_ext.rs index 6ea19d6b2d..d8f9dcd132 100644 --- a/pageserver/src/virtual_file/io_engine/tokio_epoll_uring_ext.rs +++ b/pageserver/src/virtual_file/io_engine/tokio_epoll_uring_ext.rs @@ -12,6 +12,7 @@ use tokio_util::sync::CancellationToken; use tracing::{error, info, info_span, warn, Instrument}; use utils::backoff::{DEFAULT_BASE_BACKOFF_SECONDS, DEFAULT_MAX_BACKOFF_SECONDS}; +use thread_local::ThreadLocal; use tokio_epoll_uring::{System, SystemHandle}; use crate::virtual_file::on_fatal_io_error; @@ -44,9 +45,7 @@ impl ThreadLocalState { static THREAD_LOCAL_STATE_ID: AtomicU64 = AtomicU64::new(0); -thread_local! { - static THREAD_LOCAL: ThreadLocalState = ThreadLocalState::new(); -} +static THREAD_LOCAL: ThreadLocal = ThreadLocal::new(); /// Panics if we cannot [`System::launch`]. pub async fn thread_local_system() -> Handle {