I've deployed a subgraph to a graph-node that I'm hosting myself, however the subgraph has a bug and is continuously attempting to re-execute the event handler but continuously fails on that bug. I've fixed the bug, but how would I push the updated subgraph to use all the data that's already indexed on the existing buggy subgraph and proceed to index from the specified block at which the bug was exposed?
1 Answer
You can do subgraph grafting as explained in the graph's docs, which allows you to copy(graft) data from another subgraph(in this case a buggy subgraph) onto a new subgraph(in this case the subgraph with the bug fix).
Basically add the following to your subgraph.yaml
:
graft:
base: {QmString}
block: {x - 1}
Where QmString
is the buggy subgraph_id
and x
is the block number from when the specified subgraph became buggy. For example if the subgraph became buggy at block 100
then block
should be 99
, i.e. graft the new subgraph from the buggy subgraph up to and including block 99
, then from block 100
continue re-indexing from scratch. It'll take a few minutes for the graft of new fixed subgraph from by buggy subgraph to complete, but after that's done the buggy subgraph can be removed using the graph remove
command. Example of this command:
graph remove --network local username/subgraph-name --debug --node http://127.0.0.1:8020