-
Notifications
You must be signed in to change notification settings - Fork 987
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
delete 'shallow' fh eth blks on rpc+ingestor start #4790
Conversation
when launching grpah-node with an ingestor on an eth chain with an RPC provider (i.e. not firehose), this will delete the 'shallow' blocks in chainX.blocks, so they do not cause issues to the RPC provider. It only runs on ethereum chains where firehose is not used and when ingestor is active.
@leoyvens I am not quite sure how to delete the shallow blocks in a background thread without causing a race condition with the indexer...
|
Good thinking that there could be a race condition with the ingestion. One possibility would be that blocks are deleted within the reorg threshold, and therefore should be re-ingested, but due to a race condition the ingestor believes they are already ingested and doesn't reingest. I checked and I think we're safe, ultimately because the missing parent query in But here is another idea, what if we only cleanup blocks within the reorg threshold? That would make the query much cheaper, as ultimately less blocks need to be deleted. So it would be able to use the existing index on the block number, then we wouldn't need the migration and also we wouldn't need to run the cleanup in the background. |
store/postgres/src/block_store.rs
Outdated
@@ -456,9 +456,15 @@ impl BlockStore { | |||
continue; | |||
}; | |||
} | |||
match store.chain_head_block(&&store.chain).unwrap_or(None) { |
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.
How about:
if let Some(head) = store.chain_head_block(&&store.chain)?
store/postgres/src/block_store.rs
Outdated
@@ -456,9 +456,15 @@ impl BlockStore { | |||
continue; | |||
}; | |||
} | |||
match store.chain_head_block(&&store.chain).unwrap_or(None) { | |||
Some(head) => { | |||
let lower_bound = head - ENV_VARS.reorg_threshold; |
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.
Check for overflow. Also I'd give some slack here so we don't have to worry about off by one, race conditions or whatever, maybe use 2 * ENV_VARS.reorg_threshold
.
I did a review of the code to check if it's safe to keep the final blocks ingested by Firehose in the cache when switching to RPC. The concern being that those blocks could have a
So while the situation with json formats for the If my review is wrong and something complains of deserialization failure, we can re-revisit this and resort to the alternative of truncating the whole blocks table when a switch from Firehose to RPC is detected. |
when launching grpah-node with an ingestor on an eth chain with an RPC provider (i.e. not firehose), this will delete the 'shallow' blocks in chainX.blocks, so they do not cause issues to the RPC provider.
It only runs on ethereum chains where firehose is not used and when ingestor is active.