@@ -14,8 +14,11 @@ use diesel::{
1414 sql_types:: { Nullable , Text } ,
1515} ;
1616use 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 ,
1820 schema:: EntityType ,
21+ slog:: { debug, Logger } ,
1922} ;
2023use graph:: {
2124 data:: store:: scalar:: ToPrimitive ,
@@ -890,16 +893,24 @@ pub fn update_deployment_status(
890893/// is healthy as of that block; errors are inserted according to the
891894/// `block_ptr` they contain
892895pub ( crate ) fn insert_subgraph_errors (
896+ logger : & Logger ,
893897 conn : & mut PgConnection ,
894898 id : & DeploymentHash ,
895899 deterministic_errors : & [ SubgraphError ] ,
896900 latest_block : BlockNumber ,
897901) -> 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+
898909 for error in deterministic_errors {
899910 insert_subgraph_error ( conn, error) ?;
900911 }
901912
902- check_health ( conn, id, latest_block)
913+ check_health ( logger , conn, id, latest_block)
903914}
904915
905916#[ cfg( debug_assertions) ]
@@ -918,6 +929,7 @@ pub(crate) fn error_count(
918929/// Checks if the subgraph is healthy or unhealthy as of the given block, or the subgraph latest
919930/// block if `None`, based on the presence of deterministic errors. Has no effect on failed subgraphs.
920931fn check_health (
932+ logger : & Logger ,
921933 conn : & mut PgConnection ,
922934 id : & DeploymentHash ,
923935 block : BlockNumber ,
@@ -927,7 +939,15 @@ fn check_health(
927939 let has_errors = has_deterministic_errors ( conn, id, block) ?;
928940
929941 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+ }
931951 false => ( SubgraphHealth :: Healthy , SubgraphHealth :: Unhealthy ) ,
932952 } ;
933953
@@ -979,6 +999,7 @@ pub(crate) fn entities_with_causality_region(
979999
9801000/// Reverts the errors and updates the subgraph health if necessary.
9811001pub ( crate ) fn revert_subgraph_errors (
1002+ logger : & Logger ,
9821003 conn : & mut PgConnection ,
9831004 id : & DeploymentHash ,
9841005 reverted_block : BlockNumber ,
@@ -997,7 +1018,7 @@ pub(crate) fn revert_subgraph_errors(
9971018 // The result will be the same at `reverted_block` or `reverted_block - 1` since the errors at
9981019 // `reverted_block` were just deleted, but semantically we care about `reverted_block - 1` which
9991020 // is the block being reverted to.
1000- check_health ( conn, id, reverted_block - 1 ) ?;
1021+ check_health ( & logger , conn, id, reverted_block - 1 ) ?;
10011022
10021023 // If the deployment is failed in both `failed` and `status` columns,
10031024 // update both values respectively to `false` and `healthy`. Basically
0 commit comments