From f07d6433b6df8e3546daab312ffeb81399c13233 Mon Sep 17 00:00:00 2001 From: Joonas Koivunen Date: Thu, 9 Feb 2023 13:02:07 +0200 Subject: [PATCH] fix: one leftover Arc::ptr_eq (#3573) @knizhnik noticed that one instance of `Arc::::ptr_eq` was missed in #3558. Now all `ptr_eq` which remain are in comments. --- pageserver/src/tenant/layer_map.rs | 5 ++++- pageserver/src/tenant/timeline.rs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pageserver/src/tenant/layer_map.rs b/pageserver/src/tenant/layer_map.rs index 9d8c825220..e446e34f4e 100644 --- a/pageserver/src/tenant/layer_map.rs +++ b/pageserver/src/tenant/layer_map.rs @@ -731,8 +731,11 @@ where Ok(()) } + /// Similar to `Arc::ptr_eq`, but only compares the object pointers, not vtables. + /// + /// Returns `true` if the two `Arc` point to the same layer, false otherwise. #[inline(always)] - fn compare_arced_layers(left: &Arc, right: &Arc) -> bool { + pub fn compare_arced_layers(left: &Arc, right: &Arc) -> bool { // "dyn Trait" objects are "fat pointers" in that they have two components: // - pointer to the object // - pointer to the vtable diff --git a/pageserver/src/tenant/timeline.rs b/pageserver/src/tenant/timeline.rs index 838df6d884..e1156e7270 100644 --- a/pageserver/src/tenant/timeline.rs +++ b/pageserver/src/tenant/timeline.rs @@ -2374,7 +2374,7 @@ impl Timeline { // Only one thread may call this function at a time (for this // timeline). If two threads tried to flush the same frozen // layer to disk at the same time, that would not work. - assert!(Arc::ptr_eq(&l.unwrap(), &frozen_layer)); + assert!(LayerMap::compare_arced_layers(&l.unwrap(), &frozen_layer)); // release lock on 'layers' }