From 73b011c5eec53120ad459401427dd6f2b3c7599a Mon Sep 17 00:00:00 2001 From: Mark Logan <103447440+mystenmark@users.noreply.github.com> Date: Tue, 5 Jul 2022 11:30:08 -0400 Subject: [PATCH] Work around possible compiler bug causing bogus lifetime errors to be printed occasionally (#2963) Co-authored-by: Mark Logan --- crates/sui-storage/src/mutex_table.rs | 2 +- crates/sui-storage/src/write_ahead_log.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/sui-storage/src/mutex_table.rs b/crates/sui-storage/src/mutex_table.rs index 7a4162157ecba..423c1ff8cd42b 100644 --- a/crates/sui-storage/src/mutex_table.rs +++ b/crates/sui-storage/src/mutex_table.rs @@ -59,7 +59,7 @@ impl<'b, K: Hash + 'b> MutexTable { guards } - pub async fn acquire_lock<'a>(&'a self, k: &K) -> LockGuard<'a> { + pub async fn acquire_lock<'a, 'key>(&'a self, k: &'key K) -> LockGuard<'a> { let lock_idx = self.get_lock_idx(k); LockGuard(self.lock_table[lock_idx].lock().await) } diff --git a/crates/sui-storage/src/write_ahead_log.rs b/crates/sui-storage/src/write_ahead_log.rs index f88c2f0bd0534..2c5d7fff9b62a 100644 --- a/crates/sui-storage/src/write_ahead_log.rs +++ b/crates/sui-storage/src/write_ahead_log.rs @@ -63,8 +63,11 @@ pub trait WriteAheadLog<'a, C> { /// /// Err(e) => An error occurred. #[must_use] - async fn begin_tx(&'a self, tx: &TransactionDigest, cert: &C) - -> SuiResult>; + async fn begin_tx<'b>( + &'a self, + tx: &'b TransactionDigest, + cert: &'b C, + ) -> SuiResult>; /// Recoverable TXes are TXes that we find in the log at start up (which indicates we crashed /// while processing them) or implicitly dropped TXes (which can happen because we errored @@ -258,10 +261,10 @@ where #[must_use] #[instrument(level = "debug", name = "begin_tx", skip_all)] - async fn begin_tx( + async fn begin_tx<'b>( &'a self, - tx: &TransactionDigest, - cert: &C, + tx: &'b TransactionDigest, + cert: &'b C, ) -> SuiResult>> { let mutex_guard = self.mutex_table.acquire_lock(tx).await; trace!(digest = ?tx, "acquired tx lock");