analyzer: configurable MaxBackoffTimeout #837
Merged
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.
This adds a configurable
MaxBackoffTime
to analyzers. This is useful for analyzers such asvalidatorstakinghistory
, where once caught up, we only expect new work on epoch transitions and don't need to query every 6 seconds.Additional note: the queries for fetching
validatorstakinghistory
work are not the most efficient (take ~2 seconds). I noticed this because these queries are currently using a lot of the database's CPUs—even if there's no work to be done. The idea is that with theMaxBackoffTime
change, we don't need to bloat the DB with additional indexes and just be smarter about how frequently we do the queries.Alternatives considered:
We could manually update the deployment configuration for
validatorstakinghistory
to use a "fixed-interval" once caught up. But if the analyzer falls behind (for whatever reason. e.g. node downtime etc) we would need manual intervention again to update the config. With implemented solution it should recover automatically and use a shorter timeout if there's more work to do."Epoch"-aware Item analyzer. If the ItemAnalyzer would be aware of epochs, it could then know when to call the analyzer if it is caught up. However this solution would require more (non-trivial) work to implement, which doesn't seem worth for this specific case.