Skip to content

Commit bfd4800

Browse files
evaporeiFilippo Costa
authored andcommitted
store: Unfail subgraph status properly after rewind
This is being done by changing `revert_subgraph_errors` to change both the `failed` and `status` columns in the case of both being `failed`. Without this change, rewinding failed subgraphs past the failed block would result in the `failed` status staying the same.
1 parent 0057021 commit bfd4800

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

store/postgres/src/deployment.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ pub(crate) fn revert_subgraph_errors(
775775
id: &DeploymentHash,
776776
reverted_block: BlockNumber,
777777
) -> Result<(), StoreError> {
778+
use subgraph_deployment as d;
778779
use subgraph_error as e;
779780

780781
let lower_geq = format!("lower({}) >= ", BLOCK_RANGE_COLUMN);
@@ -788,7 +789,21 @@ pub(crate) fn revert_subgraph_errors(
788789
// The result will be the same at `reverted_block` or `reverted_block - 1` since the errors at
789790
// `reverted_block` were just deleted, but semantically we care about `reverted_block - 1` which
790791
// is the block being reverted to.
791-
check_health(conn, id, reverted_block - 1)
792+
check_health(conn, id, reverted_block - 1)?;
793+
794+
// If the deployment is failed in both `failed` and `status` columns,
795+
// update both values respectively to `false` and `healthy`. Basically
796+
// unfail the statuses.
797+
update(
798+
d::table
799+
.filter(d::deployment.eq(id.as_str()))
800+
.filter(d::failed.eq(true))
801+
.filter(d::health.eq(SubgraphHealth::Failed)),
802+
)
803+
.set((d::failed.eq(false), d::health.eq(SubgraphHealth::Healthy)))
804+
.execute(conn)
805+
.map(|_| ())
806+
.map_err(StoreError::from)
792807
}
793808

794809
pub(crate) fn delete_error(conn: &PgConnection, error_id: &str) -> Result<(), StoreError> {

0 commit comments

Comments
 (0)