Refactor peers source to not emit error logs when it should not #948
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.
A recent change to the peers bootstrapper source caused it to begin emitting error logs when it should not. The reason it was emitting errors was because normally when we perform an incremental flush, we then remove all the series and blocks from the bootstrap result so that they don't get loaded into memory for no reason (increasing memory pressure).
Now that we've added the concept of a "snapshot" flush, the peers bootstrapper source needs to be aware that it should not remove series/data from memory when its doing an incremental flush that is of type snapshot, because the node is still expecting all that data to be returned for the active block. The existing code detected that the series that it was trying to remove still had data blocks in them, so it emitted an error log instead of removing them.
Correct behavior of this functionality is already tested in a combination of unit and integration tests, and all the tests passed because the defensive code made the bootstrapper do the right thing anyways, but emit an error log.
This P.R refactors the code so that the error logs will not be emitted when they should not be, upgrades the existing error messages to InvariantViolated, and leaves the existing tests intact.
I also went ahead and removed some dead code that was left behind from a previous migration and is no longer required.