Add support to backfill actor events + resuming when left off #10939
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related: #10807
Context
When lotus is configured to enable indexing of actor events (when
EnableEthRPC=true
andDisableHistoricFilterAPI=false
) then Lotus will observe for new tipset and store all the actor events in a sqlite table stored atsqlite/events.db
. We however, don't have any way to backfill this table which is what this PR is aboutI tried first to implement this backfilling using lotus-shed (as we have for backfilling msgindex and eth txhahses) but I had some issues getting the required dependencies to work there, so I ended up integrating this into the lotus node directy.
This backfill is guarded behind a new lotus config
EnableEventBackfillOnStartup
which now defaults to false. When set to true, then Lotus will start a background go routine which walks up the chain to collect the actor events. It then checks the sqlite database if that actor event are missing from the database and inserts them if that is the case.To gracefully handle restarts when backfilling, we mark the current process in a new table
event_backfilled
so we will resume from where we left of if the backfill process was interrupted for any reason.Test plan
Backfill active node that is already storing events
As expected, backfilling should not have any side effects on a node that is already saving actor events.
Backfill a node that had never stored any events
Verify backfill results
I compared the
events.db
that was generated from scratch via backfill to anotherevents.db
which was generated from by an active lotus node. I attached the second database asevents2
and used the following sql to verify there are no missing events:The nice thing is that the backfilled actor events naturally do not contain any duplicates as is generated during a live node as there are no reverts