-
Notifications
You must be signed in to change notification settings - Fork 980
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
Update nonFatalErrors in subgraphs.subgraph_deployment table #4615
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -506,7 +506,7 @@ fn subgraph_error() { | |
|
||
assert!(count() == 0); | ||
|
||
transact_errors(&store, &deployment, BLOCKS[1].clone(), vec![error]) | ||
transact_errors(&store, &deployment, BLOCKS[1].clone(), vec![error], false) | ||
.await | ||
.unwrap(); | ||
assert!(count() == 1); | ||
|
@@ -520,7 +520,7 @@ fn subgraph_error() { | |
}; | ||
|
||
// Inserting the same error is allowed but ignored. | ||
transact_errors(&store, &deployment, BLOCKS[2].clone(), vec![error]) | ||
transact_errors(&store, &deployment, BLOCKS[2].clone(), vec![error], false) | ||
.await | ||
.unwrap(); | ||
assert!(count() == 1); | ||
|
@@ -533,7 +533,7 @@ fn subgraph_error() { | |
deterministic: false, | ||
}; | ||
|
||
transact_errors(&store, &deployment, BLOCKS[3].clone(), vec![error2]) | ||
transact_errors(&store, &deployment, BLOCKS[3].clone(), vec![error2], false) | ||
.await | ||
.unwrap(); | ||
assert!(count() == 2); | ||
|
@@ -542,6 +542,64 @@ fn subgraph_error() { | |
}) | ||
} | ||
|
||
#[test] | ||
fn subgraph_non_fatal_error() { | ||
test_store::run_test_sequentially(|store| async move { | ||
let subgraph_store = store.subgraph_store(); | ||
let subgraph_id = DeploymentHash::new("subgraph_non_fatal_error").unwrap(); | ||
let deployment = | ||
test_store::create_test_subgraph(&subgraph_id, "type Foo { id: ID! }").await; | ||
|
||
let count = || -> usize { | ||
let store = store.subgraph_store(); | ||
let count = store.error_count(&subgraph_id).unwrap(); | ||
println!("count: {}", count); | ||
count | ||
}; | ||
|
||
let error = SubgraphError { | ||
subgraph_id: subgraph_id.clone(), | ||
message: "test".to_string(), | ||
block_ptr: Some(BLOCKS[1].clone()), | ||
handler: None, | ||
deterministic: true, | ||
}; | ||
|
||
assert!(count() == 0); | ||
|
||
transact_errors(&store, &deployment, BLOCKS[1].clone(), vec![error], true) | ||
.await | ||
.unwrap(); | ||
assert!(count() == 1); | ||
|
||
let info = subgraph_store.status_for_id(deployment.id); | ||
|
||
assert!(info.non_fatal_errors.len() == 1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's generally better to use |
||
assert!(info.health == SubgraphHealth::Unhealthy); | ||
|
||
let error2 = SubgraphError { | ||
subgraph_id: subgraph_id.clone(), | ||
message: "test2".to_string(), | ||
block_ptr: None, | ||
handler: None, | ||
deterministic: false, | ||
}; | ||
|
||
// Inserting non deterministic errors will increase error count but not count of non fatal errors | ||
transact_errors(&store, &deployment, BLOCKS[2].clone(), vec![error2], false) | ||
.await | ||
.unwrap(); | ||
assert!(count() == 2); | ||
|
||
let info = subgraph_store.status_for_id(deployment.id); | ||
|
||
assert!(info.non_fatal_errors.len() == 1); | ||
assert!(info.health == SubgraphHealth::Unhealthy); | ||
|
||
test_store::remove_subgraph(&subgraph_id); | ||
}) | ||
} | ||
|
||
#[test] | ||
fn fatal_vs_non_fatal() { | ||
async fn setup() -> DeploymentLocator { | ||
|
@@ -592,7 +650,7 @@ fn fatal_vs_non_fatal() { | |
.await | ||
.unwrap()); | ||
|
||
transact_errors(&store, &deployment, BLOCKS[1].clone(), vec![error()]) | ||
transact_errors(&store, &deployment, BLOCKS[1].clone(), vec![error()], false) | ||
.await | ||
.unwrap(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a leftover from debugging.