Filter obsolete layer files from an older generation from heatmap #12809
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.
Problem
In some edge case in production we've seen a tenant stuck with a secondary that downloads an older generation layer file than the one in the index and then when it becomes primary each time we do a deploy it logs an error about the file on disk being the wrong length. This is generally harmless for user correctness but is not optimal and an alarming error.
Summary of changes
This PR contains the 3 lines of fix (which is to check generation matches while including existing files in the next layer map) but is mostly testing method changes to setup the right state to test that. It feels like a low-risk enough change that a huge effort or refactor of testing code to make it testable probably isn't warranted, but this seemed to be small enough and not too unpleasant to be worth keeping. I'm open to feedback though if reviewers disagree.
There is one FIXME comment in timeline
reconcile
because I found a subtle issue that is kind of a bug but neutralised by implicit semantics right now. We should probably keep that in mind in future so a comment seems useful, but the fix seemed like too much scope creep to include here since there will be zero impact immediately anyway. If others would prefer a fix and agree we could make that a follow on but I suspect there is higher value work to do!