Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ipfs timeout detection #2584

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions core/src/subgraph/instance_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use graph::{components::ethereum::NodeCapabilities, data::store::scalar::Bytes};

use super::loader::load_dynamic_data_sources;
use super::SubgraphInstance;
use crate::subgraph::registrar::IPFS_SUBGRAPH_LOADING_TIMEOUT;

lazy_static! {
/// Size limit of the entity LFU cache, in bytes.
Expand Down Expand Up @@ -262,14 +261,6 @@ where
let logger = logger_factory.component_logger("SubgraphInstanceManager", None);
let logger_factory = logger_factory.with_parent(logger.clone());

let link_resolver = Arc::new(
link_resolver
.as_ref()
.clone()
.with_timeout(*IPFS_SUBGRAPH_LOADING_TIMEOUT)
.with_retries(),
);

SubgraphInstanceManager {
logger_factory,
subgraph_store,
Expand Down Expand Up @@ -323,7 +314,8 @@ where
let mut manifest = SubgraphManifest::resolve_from_raw(
deployment.hash.cheap_clone(),
manifest,
&*link_resolver,
// Allow for infinite retries for subgraph definition files.
&link_resolver.as_ref().clone().with_retries(),
&logger,
)
.await
Expand Down
25 changes: 3 additions & 22 deletions core/src/subgraph/registrar.rs
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
use std::collections::HashSet;
use std::env;
use std::time::{Duration, Instant};
use std::time::Instant;

use async_trait::async_trait;
use graph::blockchain::BlockchainMap;
use lazy_static::lazy_static;

use graph::blockchain::Blockchain;
use graph::blockchain::BlockchainMap;
use graph::components::store::{DeploymentId, DeploymentLocator, SubscriptionManager};
use graph::data::subgraph::schema::SubgraphDeploymentEntity;
use graph::prelude::{
CreateSubgraphResult, SubgraphAssignmentProvider as SubgraphAssignmentProviderTrait,
SubgraphRegistrar as SubgraphRegistrarTrait, *,
};

lazy_static! {
// The timeout for IPFS requests in seconds
pub static ref IPFS_SUBGRAPH_LOADING_TIMEOUT: Duration = Duration::from_secs(
env::var("GRAPH_IPFS_SUBGRAPH_LOADING_TIMEOUT")
.unwrap_or("60".into())
.parse::<u64>()
.expect("invalid IPFS subgraph loading timeout")
);
}

pub struct SubgraphRegistrar<C, L, P, S, SM> {
logger: Logger,
logger_factory: LoggerFactory,
Expand Down Expand Up @@ -61,13 +48,7 @@ where
SubgraphRegistrar {
logger,
logger_factory,
resolver: Arc::new(
resolver
.as_ref()
.clone()
.with_timeout(*IPFS_SUBGRAPH_LOADING_TIMEOUT)
.with_retries(),
),
resolver: Arc::new(resolver.as_ref().clone().with_retries()),
provider,
store,
subscription_manager,
Expand Down
6 changes: 2 additions & 4 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ those.

- `GRAPH_MAPPING_HANDLER_TIMEOUT`: amount of time a mapping handler is allowed to
take (in seconds, default is unlimited)
- `GRAPH_IPFS_SUBGRAPH_LOADING_TIMEOUT`: timeout for IPFS requests made to load
subgraph files from IPFS (in seconds, default is 60).
- `GRAPH_IPFS_TIMEOUT`: timeout for IPFS requests from mappings using `ipfs.cat`
or `ipfs.map` (in seconds, default is 30).
- `GRAPH_IPFS_TIMEOUT`: timeout for IPFS, which includes requests for manifest files
and from mappings using `ipfs.cat` or `ipfs.map` (in seconds, default is 30).
- `GRAPH_MAX_IPFS_FILE_BYTES`: maximum size for a file that can be retrieved
with `ipfs.cat` (in bytes, default is unlimited)
- `GRAPH_MAX_IPFS_MAP_FILE_SIZE`: maximum size of files that can be processed
Expand Down