fix weak ptr

Signed-off-by: Alex Chi <chi@neon.tech>
This commit is contained in:
Alex Chi
2023-06-26 14:33:00 -04:00
parent 91f28cb516
commit 9ed6ad1d24
2 changed files with 7 additions and 8 deletions

View File

@@ -39,17 +39,16 @@ pub struct LayerInUseRead(tokio::sync::OwnedRwLockReadGuard<()>);
pub struct DeleteGuard(Arc<tokio::sync::OwnedMutexGuard<()>>);
impl LayerCache {
pub fn new(timeline: Weak<Timeline>) -> Self {
let timeline_arc = timeline.upgrade().unwrap();
pub fn new(timeline: Weak<Timeline>, tenant_id: TenantId, timeline_id: TimelineId) -> Self {
Self {
layers_operation_lock: Arc::new(tokio::sync::RwLock::new(())),
layers_removal_lock: Arc::new(tokio::sync::Mutex::new(())),
mapping: Mutex::new(HashMap::new()),
timeline,
tenant_id: timeline_arc.tenant_id,
timeline_id: timeline_arc.timeline_id,
tenant_id_str: timeline_arc.tenant_id.to_string(),
timeline_id_str: timeline_arc.timeline_id.to_string(),
timeline: timeline,
tenant_id: tenant_id,
timeline_id: timeline_id,
tenant_id_str: tenant_id.to_string(),
timeline_id_str: timeline_id.to_string(),
}
}

View File

@@ -1421,7 +1421,7 @@ impl Timeline {
tenant_id,
pg_version,
layers: tokio::sync::RwLock::new((LayerMap::default(), LayerMapping::new())),
lcache: LayerCache::new(myself.clone()),
lcache: LayerCache::new(myself.clone(), tenant_id, timeline_id),
wanted_image_layers: Mutex::new(None),
walredo_mgr,