Skip to content

Commit a25e2b7

Browse files
goffrieConvex, Inc.
authored andcommitted
Remove the claim instance lock (#43993)
GitOrigin-RevId: 58ecc71e53e512ce5d35cecf4f943125a8496f1f
1 parent adee893 commit a25e2b7

File tree

3 files changed

+1
-44
lines changed

3 files changed

+1
-44
lines changed

crates/common/src/knobs.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,11 +1386,6 @@ pub static MAX_IMPORT_AGE: LazyLock<Duration> =
13861386
pub static PARTITION_LOADER_MAX_STALE_SECS: LazyLock<Duration> =
13871387
LazyLock::new(|| Duration::from_secs(env_config("PARTITION_LOADER_MAX_STALE_SECS", 1)));
13881388

1389-
/// Seconds to wait before timing out when trying to acquire the lock for
1390-
/// claiming an instance in big-brain.
1391-
pub static CLAIM_INSTANCE_TIMEOUT_SECS: LazyLock<Duration> =
1392-
LazyLock::new(|| Duration::from_secs(env_config("CLAIM_INSTANCE_TIMEOUT_SECS", 10)));
1393-
13941389
/// The maximum number of bytes to buffer in an multipart upload.
13951390
/// There may be stricter limits imposed by the storage provider, but this is
13961391
/// the target max size for the buffer to protect against memory exhaustion.

crates/common/src/runtime/mod.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -584,32 +584,6 @@ pub struct TimeoutError {
584584
duration: Duration,
585585
}
586586

587-
pub struct MutexWithTimeout<T: Send> {
588-
timeout: Duration,
589-
mutex: tokio::sync::Mutex<T>,
590-
}
591-
592-
impl<T: Send> MutexWithTimeout<T> {
593-
pub fn new(timeout: Duration, value: T) -> Self {
594-
Self {
595-
timeout,
596-
mutex: tokio::sync::Mutex::new(value),
597-
}
598-
}
599-
600-
pub async fn acquire_lock_with_timeout(
601-
&self,
602-
) -> anyhow::Result<tokio::sync::MutexGuard<'_, T>> {
603-
let acquire_lock = async { Ok(self.mutex.lock().await) };
604-
select_biased! {
605-
result = acquire_lock.fuse() => result,
606-
_ = tokio::time::sleep(self.timeout).fuse() => {
607-
anyhow::bail!(TimeoutError{description: "acquire_lock", duration: self.timeout});
608-
},
609-
}
610-
}
611-
}
612-
613587
/// Binds the current tracing & sentry contexts to the provided future.
614588
pub fn propagate_tracing<F: Future>(
615589
f: F,

crates/common/src/runtime/testing/mod.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,7 @@ impl RngCore for TestRng {
208208
#[cfg(test)]
209209
mod tests {
210210
use super::*;
211-
use crate::runtime::{
212-
JoinError,
213-
MutexWithTimeout,
214-
};
211+
use crate::runtime::JoinError;
215212

216213
#[test]
217214
fn test_runtime2() -> anyhow::Result<()> {
@@ -232,13 +229,4 @@ mod tests {
232229
});
233230
Ok(())
234231
}
235-
236-
#[tokio::test]
237-
async fn test_mutex_with_timeout() -> anyhow::Result<()> {
238-
let mutex = MutexWithTimeout::new(Duration::from_secs(1), ());
239-
let _lock = mutex.acquire_lock_with_timeout().await?;
240-
// Trying to acquire lock while the lock is already held should timeout
241-
assert!(mutex.acquire_lock_with_timeout().await.is_err());
242-
Ok(())
243-
}
244232
}

0 commit comments

Comments
 (0)