Skip to content

Commit 357517f

Browse files
authored
ipfs: Remove concurrency limit, rely on rate limit (#4570)
* ipfs: Remove concurrency limit, rely on rate limit The concurrency limit, because it uses a semaphore, had unfortunate interactions with the use of `call_all` in the polling monitor. `CallAll` can internally have requests which are holding the semaphore, so it must be polled regularly to check on those requests. If the task holding the `CallAll` hangs on some other future, that can lead to a deadlock. In our case, it can hang in the `response_sender.send((id, response)).await`, if the channel is full and the subgraph runner takes a long time to check it. This could be fixed, but the footgun would remain so it seemed best to rely only on the rate limit which can't deadlock. * polling monitor: Log when not found
1 parent 9fea677 commit 357517f

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

core/src/polling_monitor/ipfs_service.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn ipfs_service(
1717
client: IpfsClient,
1818
max_file_size: u64,
1919
timeout: Duration,
20-
concurrency_and_rate_limit: u16,
20+
rate_limit: u16,
2121
) -> IpfsService {
2222
let ipfs = IpfsServiceInner {
2323
client,
@@ -26,8 +26,7 @@ pub fn ipfs_service(
2626
};
2727

2828
let svc = ServiceBuilder::new()
29-
.rate_limit(concurrency_and_rate_limit.into(), Duration::from_secs(1))
30-
.concurrency_limit(concurrency_and_rate_limit as usize)
29+
.rate_limit(rate_limit.into(), Duration::from_secs(1))
3130
.service_fn(move |req| ipfs.cheap_clone().call_inner(req))
3231
.boxed();
3332

core/src/polling_monitor/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ where
161161

162162
// Object not found, push the id to the back of the queue.
163163
Ok((id, None)) => {
164+
debug!(logger, "not found on polling"; "object_id" => id.to_string());
165+
164166
metrics.not_found.inc();
165167
queue.push_back(id);
166168
}

docs/environment-variables.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ those.
7878
may use (in bytes, defaults to 256MB).
7979
- `GRAPH_MAX_IPFS_CACHE_SIZE`: maximum number of files cached (defaults to 50).
8080
- `GRAPH_MAX_IPFS_CACHE_FILE_SIZE`: maximum size of each cached file (in bytes, defaults to 1MiB).
81-
- `GRAPH_IPFS_REQUEST_LIMIT`: Limits both concurrent and per second requests to IPFS for file data
82-
sources. Defaults to 100.
81+
- `GRAPH_IPFS_REQUEST_LIMIT`: Limits the number of requests per second to IPFS for file data sources.
82+
Defaults to 100.
8383

8484
## GraphQL
8585

graph/src/env/mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct EnvVarsMapping {
4949
/// bytes). Defaults to 256 MiB.
5050
pub max_ipfs_file_bytes: usize,
5151

52-
/// Limits both concurrent and per second requests to IPFS for file data sources.
52+
/// Limits per second requests to IPFS for file data sources.
5353
///
5454
/// Set by the environment variable `GRAPH_IPFS_REQUEST_LIMIT`. Defaults to 100.
5555
pub ipfs_request_limit: u16,

0 commit comments

Comments
 (0)