experiment: what if we make Handle !Send so it can't be held across await points

Result: the whole point of having a Handle at hand is to be holding a GateGuard
while performing a Timeline operation. Dont' do it.
This commit is contained in:
Christian Schwarz
2025-01-14 13:30:48 +01:00
parent 6b22acba9b
commit b44070d0c7

View File

@@ -173,6 +173,7 @@ pub(crate) struct ShardTimelineId {
pub(crate) struct Handle<T: Types> {
timeline: Arc<T::Timeline>,
inner: tokio::sync::OwnedMutexGuard<HandleInner>,
_dont_hold_across_await_points: std::marker::PhantomData<*const u8>,
}
pub(crate) struct WeakHandle<T: Types> {
timeline: Arc<T::Timeline>,
@@ -400,6 +401,7 @@ impl<T: Types> Cache<T> {
Ok(Handle {
timeline,
inner: handle_locked,
_dont_hold_across_await_points: Default::default(),
})
}
Err(e) => Err(GetError::TenantManager(e)),
@@ -421,6 +423,7 @@ impl<T: Types> WeakHandle<T> {
HandleInner::KeepingTimelineGateOpen { .. } => Ok(Handle {
timeline: Arc::clone(&self.timeline),
inner: lock_guard,
_dont_hold_across_await_points: Default::default(),
}),
HandleInner::ShutDown => Err(HandleUpgradeError::ShutDown),
}
@@ -439,6 +442,9 @@ impl<T: Types> Deref for Handle<T> {
}
impl<T: Types> Handle<T> {
pub(crate) fn timeline(&self) -> &T::Timeline {
&self.timeline
}
pub(crate) fn downgrade(&self) -> WeakHandle<T> {
WeakHandle {
timeline: Arc::clone(&self.timeline),