diff --git a/pageserver/src/layered_repository.rs b/pageserver/src/layered_repository.rs index 5ab6097960..60b0e921ce 100644 --- a/pageserver/src/layered_repository.rs +++ b/pageserver/src/layered_repository.rs @@ -2220,12 +2220,6 @@ pub mod tests { } let cutoff = tline.get_last_record_lsn(); - let parts = keyspace - .clone() - .to_keyspace() - .partition(TEST_FILE_SIZE as u64); - tline.hint_partitioning(parts.clone(), lsn)?; - tline.update_gc_info(Vec::new(), cutoff); tline.checkpoint(CheckpointConfig::Forced)?; tline.compact()?; @@ -2268,9 +2262,6 @@ pub mod tests { keyspace.add_key(test_key); } - let parts = keyspace.to_keyspace().partition(TEST_FILE_SIZE as u64); - tline.hint_partitioning(parts, lsn)?; - for _ in 0..50 { for _ in 0..NUM_KEYS { lsn = Lsn(lsn.0 + 0x10); @@ -2342,9 +2333,6 @@ pub mod tests { keyspace.add_key(test_key); } - let parts = keyspace.to_keyspace().partition(TEST_FILE_SIZE as u64); - tline.hint_partitioning(parts, lsn)?; - let mut tline_id = TIMELINE_ID; for _ in 0..50 { let new_tline_id = ZTimelineId::generate(); diff --git a/pageserver/src/pgdatadir_mapping.rs b/pageserver/src/pgdatadir_mapping.rs index fbd1b56180..2e0040f0c0 100644 --- a/pageserver/src/pgdatadir_mapping.rs +++ b/pageserver/src/pgdatadir_mapping.rs @@ -18,7 +18,7 @@ use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::ops::Range; use std::sync::atomic::{AtomicIsize, Ordering}; -use std::sync::{Arc, RwLock, RwLockReadGuard}; +use std::sync::{Arc, Mutex, RwLockReadGuard}; use tracing::{debug, error, trace, warn}; use zenith_utils::bin_ser::BeSer; use zenith_utils::lsn::Lsn; @@ -37,7 +37,7 @@ where pub tline: Arc, /// When did we last calculate the partitioning? - partitioning: RwLock<(KeyPartitioning, Lsn)>, + partitioning: Mutex<(KeyPartitioning, Lsn)>, /// Configuration: how often should the partitioning be recalculated. repartition_threshold: u64, @@ -50,7 +50,7 @@ impl DatadirTimeline { pub fn new(tline: Arc, repartition_threshold: u64) -> Self { DatadirTimeline { tline, - partitioning: RwLock::new((KeyPartitioning::new(), Lsn(0))), + partitioning: Mutex::new((KeyPartitioning::new(), Lsn(0))), current_logical_size: AtomicIsize::new(0), repartition_threshold, } @@ -389,13 +389,11 @@ impl DatadirTimeline { } pub fn repartition(&self, lsn: Lsn) -> Result<(KeyPartitioning, Lsn)> { - let partitioning_guard = self.partitioning.read().unwrap(); + let mut partitioning_guard = self.partitioning.lock().unwrap(); if partitioning_guard.1 == Lsn(0) || lsn.0 - partitioning_guard.1 .0 > self.repartition_threshold { let keyspace = self.collect_keyspace(lsn)?; - drop(partitioning_guard); - let mut partitioning_guard = self.partitioning.write().unwrap(); let partitioning = keyspace.partition(TARGET_FILE_SIZE_BYTES); *partitioning_guard = (partitioning, lsn); return Ok((partitioning_guard.0.clone(), lsn));