Skip to content

Commit 2af8103

Browse files
committed
Drop redundant tokio::timeouts for VSS IO
Now that we rely on `reqwest` v0.12.* retry logic as well as client-side timeouts, we can address the remaining TODOs here and simply drop the redundant `tokio::timeout`s we previously added as a safeguard to blocking tasks (even though in the worst cases we saw they never actually fired).
1 parent a375179 commit 2af8103

File tree

1 file changed

+4
-41
lines changed

1 file changed

+4
-41
lines changed

src/io/vss_store.rs

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ enum VssSchemaVersion {
5858
// We set this to a small number of threads that would still allow to make some progress if one
5959
// would hit a blocking case
6060
const INTERNAL_RUNTIME_WORKERS: usize = 2;
61-
const VSS_IO_TIMEOUT: Duration = Duration::from_secs(5);
6261

6362
/// A [`KVStoreSync`] implementation that writes to and reads from a [VSS](https://github.com/lightningdevkit/vss-server/blob/main/README.md) backend.
6463
pub struct VssStore {
@@ -167,16 +166,7 @@ impl KVStoreSync for VssStore {
167166
let inner = Arc::clone(&self.inner);
168167
let fut =
169168
async move { inner.read_internal(primary_namespace, secondary_namespace, key).await };
170-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
171-
// times out.
172-
tokio::task::block_in_place(move || {
173-
internal_runtime.block_on(async move {
174-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
175-
let msg = "VssStore::read timed out";
176-
Error::new(ErrorKind::Other, msg)
177-
})
178-
})?
179-
})
169+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
180170
}
181171

182172
fn write(
@@ -206,16 +196,7 @@ impl KVStoreSync for VssStore {
206196
)
207197
.await
208198
};
209-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
210-
// times out.
211-
tokio::task::block_in_place(move || {
212-
internal_runtime.block_on(async move {
213-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
214-
let msg = "VssStore::write timed out";
215-
Error::new(ErrorKind::Other, msg)
216-
})
217-
})?
218-
})
199+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
219200
}
220201

221202
fn remove(
@@ -245,16 +226,7 @@ impl KVStoreSync for VssStore {
245226
)
246227
.await
247228
};
248-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
249-
// times out.
250-
tokio::task::block_in_place(move || {
251-
internal_runtime.block_on(async move {
252-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
253-
let msg = "VssStore::remove timed out";
254-
Error::new(ErrorKind::Other, msg)
255-
})
256-
})?
257-
})
229+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
258230
}
259231

260232
fn list(&self, primary_namespace: &str, secondary_namespace: &str) -> io::Result<Vec<String>> {
@@ -267,16 +239,7 @@ impl KVStoreSync for VssStore {
267239
let secondary_namespace = secondary_namespace.to_string();
268240
let inner = Arc::clone(&self.inner);
269241
let fut = async move { inner.list_internal(primary_namespace, secondary_namespace).await };
270-
// TODO: We could drop the timeout here once we ensured vss-client's Retry logic always
271-
// times out.
272-
tokio::task::block_in_place(move || {
273-
internal_runtime.block_on(async move {
274-
tokio::time::timeout(VSS_IO_TIMEOUT, fut).await.map_err(|_| {
275-
let msg = "VssStore::list timed out";
276-
Error::new(ErrorKind::Other, msg)
277-
})
278-
})?
279-
})
242+
tokio::task::block_in_place(move || internal_runtime.block_on(fut))
280243
}
281244
}
282245

0 commit comments

Comments
 (0)