Skip to content

Commit cbfb912

Browse files
committed
core, graph: Make maximum backoff for file data sources configurable
1 parent 8df026d commit cbfb912

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

core/src/polling_monitor/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use std::task::Poll;
1010
use std::time::Duration;
1111

1212
use graph::cheap_clone::CheapClone;
13+
use graph::env::ENV_VARS;
1314
use graph::futures03::future::BoxFuture;
1415
use graph::futures03::stream::StreamExt;
1516
use graph::futures03::{stream, Future, FutureExt, TryFutureExt};
@@ -29,8 +30,6 @@ pub use ipfs_service::{ipfs_service, IpfsService};
2930

3031
const MIN_BACKOFF: Duration = Duration::from_secs(5);
3132

32-
const MAX_BACKOFF: Duration = Duration::from_secs(600);
33-
3433
struct Backoffs<ID> {
3534
backoff_maker: ExponentialBackoffMaker,
3635
backoffs: HashMap<ID, ExponentialBackoff>,
@@ -42,7 +41,7 @@ impl<ID: Eq + Hash> Backoffs<ID> {
4241
Self {
4342
backoff_maker: ExponentialBackoffMaker::new(
4443
MIN_BACKOFF,
45-
MAX_BACKOFF,
44+
ENV_VARS.mappings.fds_max_backoff,
4645
1.0,
4746
HasherRng::new(),
4847
)

graph/src/env/mappings.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub struct EnvVarsMapping {
7878
/// measure and can be removed after 2025-07-01, once we are sure the
7979
/// new behavior works as intended.
8080
pub store_errors_are_nondeterministic: bool,
81+
82+
/// Maximum backoff time for FDS requests. Set by
83+
/// `GRAPH_FDS_MAX_BACKOFF` in seconds, defaults to 600.
84+
pub fds_max_backoff: Duration,
8185
}
8286

8387
// This does not print any values avoid accidentally leaking any sensitive env vars
@@ -116,6 +120,7 @@ impl TryFrom<InnerMappingHandlers> for EnvVarsMapping {
116120
allow_non_deterministic_ipfs: x.allow_non_deterministic_ipfs.0,
117121
disable_declared_calls: x.disable_declared_calls.0,
118122
store_errors_are_nondeterministic: x.store_errors_are_nondeterministic.0,
123+
fds_max_backoff: Duration::from_secs(x.fds_max_backoff),
119124
};
120125
Ok(vars)
121126
}
@@ -157,6 +162,8 @@ pub struct InnerMappingHandlers {
157162
disable_declared_calls: EnvVarBoolean,
158163
#[envconfig(from = "GRAPH_STORE_ERRORS_ARE_NON_DETERMINISTIC", default = "false")]
159164
store_errors_are_nondeterministic: EnvVarBoolean,
165+
#[envconfig(from = "GRAPH_FDS_MAX_BACKOFF", default = "600")]
166+
fds_max_backoff: u64,
160167
}
161168

162169
fn validate_ipfs_cache_location(path: PathBuf) -> Result<PathBuf, anyhow::Error> {

0 commit comments

Comments
 (0)