-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Allow Realtime Fetcher to wait for small skips #2470
Conversation
cd89b32
to
459a183
Compare
Pull Request Test Coverage Report for Build 29fbc4c9-5280-4b2a-9dc8-03c80c376022
💛 - Coveralls |
459a183
to
4597a92
Compare
4597a92
to
7e883c3
Compare
30e35c4
to
23521f0
Compare
@vbaranov sure, done |
45a0256
to
11879de
Compare
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.
From stg (after installing the current update):
2019-08-02T11:58:21.543 application=indexer fetcher=block_realtime block_number=8271158 count=179 [debug] fetching transaction receipts
2019-08-02T11:58:23.669 application=indexer fetcher=block_realtime block_number=8271158 count=179 [debug] fetching transaction receipts
Should this PR cover this issue? Or this is not an issue at all?
Hey @vbaranov yes it should cover this in most cases where it is an issue, but it may very well not be in your specific case. For instance this could be a legitimate reorg and you'd see that in the logs. |
I didn't see reorg in logs. In addition, this block not in the list of forked. One more example (ETH Mainnet chain):
|
592772d
to
e403fb2
Compare
b42d043
to
e453af7
Compare
Problem: Sometimes the realtime fetcher's `newHeads` websocket subscription skips a small amount of block numbers, just to be followed by those very same numbers that were skipped, without repeating the number that caused the skipping. This may be cause by out-of-order events or be a legitimate reorg, but in any case this causes close-in-time refetching which in turn leads to async insertions problems. Solution: allow the Realtime fetcher to keep track of a small (settable) skip and wait for the block number inside the skip to arrive before fetching the whole window. Obviously if it gets notified of the blocks following the skip (or it is forced into polling) the whole window gets fetched and inserted.
e453af7
to
e8c2fa5
Compare
Closes #1556
and solves this error of
fetcher=internal_transaction
:Motivation
While searching for the root cause of the
internal_transactions
issue an odd correlation with the order of the realtime's fetcher indexed block was noticed and found to be consistently happening.Upon further inspection this also seems to be the cause (or at least one of the causes) for that same fetcher to be refetching the same block multiple time.
The source of the problem
These errors both seem to happen when the
newHeads
websocket subscription skips a small amount of block numbers, just to be followed by those very same numbers that were skipped, without repeating the number that caused the skipping. For example:This is (correctly) handled by the fetcher as the case number 3 described here: #1189
and it behaves like this:
effectively treating it as a reorg.
Why this causes both errors
This kind of block number mis-ordering seems to be happening very often and may very well be caused by an incorrect order of events.
Even if they are indeed reorgs, this causes a lot of close-in-time refetching (problem n.1) and because
internal_transactions
get fetched asynchronously this may happen after the reorg but before the block has been refetched (so theirtransactions
do not exist in the DB yet <-> problem n.2).For clarity, using the same numbers of the example abobe, this order of events can happen:
internal_transactions
contained in the new version of the block. These will fail to insert.Changelog
Bug Fixes
The proposed solution is to allow the Realtime fetcher ignore small (settable) skips and wait for the blocks following the last one inserted to arrive in order.
Obviously if it gets notified of the blocks following the maximum allowed skip the whole window gets fetched and inserted.
This way small skips will not create multiple fetching of the same blocks and the fetching will be at most a few blocks old.
Checklist for your PR
CHANGELOG.md
with this PR