@@ -14,8 +14,11 @@ use diesel::{
14
14
sql_types:: { Nullable , Text } ,
15
15
} ;
16
16
use graph:: {
17
- blockchain:: block_stream:: FirehoseCursor , data:: subgraph:: schema:: SubgraphError , env:: ENV_VARS ,
17
+ blockchain:: block_stream:: FirehoseCursor ,
18
+ data:: subgraph:: schema:: SubgraphError ,
19
+ env:: ENV_VARS ,
18
20
schema:: EntityType ,
21
+ slog:: { debug, Logger } ,
19
22
} ;
20
23
use graph:: {
21
24
data:: store:: scalar:: ToPrimitive ,
@@ -890,16 +893,24 @@ pub fn update_deployment_status(
890
893
/// is healthy as of that block; errors are inserted according to the
891
894
/// `block_ptr` they contain
892
895
pub ( crate ) fn insert_subgraph_errors (
896
+ logger : & Logger ,
893
897
conn : & mut PgConnection ,
894
898
id : & DeploymentHash ,
895
899
deterministic_errors : & [ SubgraphError ] ,
896
900
latest_block : BlockNumber ,
897
901
) -> Result < ( ) , StoreError > {
902
+ debug ! (
903
+ logger,
904
+ "Inserting deterministic errors to the db" ;
905
+ "subgraph" => id. to_string( ) ,
906
+ "errors" => deterministic_errors. len( )
907
+ ) ;
908
+
898
909
for error in deterministic_errors {
899
910
insert_subgraph_error ( conn, error) ?;
900
911
}
901
912
902
- check_health ( conn, id, latest_block)
913
+ check_health ( logger , conn, id, latest_block)
903
914
}
904
915
905
916
#[ cfg( debug_assertions) ]
@@ -918,6 +929,7 @@ pub(crate) fn error_count(
918
929
/// Checks if the subgraph is healthy or unhealthy as of the given block, or the subgraph latest
919
930
/// block if `None`, based on the presence of deterministic errors. Has no effect on failed subgraphs.
920
931
fn check_health (
932
+ logger : & Logger ,
921
933
conn : & mut PgConnection ,
922
934
id : & DeploymentHash ,
923
935
block : BlockNumber ,
@@ -927,7 +939,15 @@ fn check_health(
927
939
let has_errors = has_deterministic_errors ( conn, id, block) ?;
928
940
929
941
let ( new, old) = match has_errors {
930
- true => ( SubgraphHealth :: Unhealthy , SubgraphHealth :: Healthy ) ,
942
+ true => {
943
+ debug ! (
944
+ logger,
945
+ "Subgraph has deterministic errors. Marking as unhealthy" ;
946
+ "subgraph" => id. to_string( ) ,
947
+ "block" => block
948
+ ) ;
949
+ ( SubgraphHealth :: Unhealthy , SubgraphHealth :: Healthy )
950
+ }
931
951
false => ( SubgraphHealth :: Healthy , SubgraphHealth :: Unhealthy ) ,
932
952
} ;
933
953
@@ -979,6 +999,7 @@ pub(crate) fn entities_with_causality_region(
979
999
980
1000
/// Reverts the errors and updates the subgraph health if necessary.
981
1001
pub ( crate ) fn revert_subgraph_errors (
1002
+ logger : & Logger ,
982
1003
conn : & mut PgConnection ,
983
1004
id : & DeploymentHash ,
984
1005
reverted_block : BlockNumber ,
@@ -997,7 +1018,7 @@ pub(crate) fn revert_subgraph_errors(
997
1018
// The result will be the same at `reverted_block` or `reverted_block - 1` since the errors at
998
1019
// `reverted_block` were just deleted, but semantically we care about `reverted_block - 1` which
999
1020
// is the block being reverted to.
1000
- check_health ( conn, id, reverted_block - 1 ) ?;
1021
+ check_health ( & logger , conn, id, reverted_block - 1 ) ?;
1001
1022
1002
1023
// If the deployment is failed in both `failed` and `status` columns,
1003
1024
// update both values respectively to `false` and `healthy`. Basically
0 commit comments