shards: handle failed cached List for selectRepoSet #864
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.
If we failed to List the repositories when loading a shard we would never search it due to selectRepoSet optimization. In practice this feels very rare to happen (only for logic error or disk corruption). However, in those cases we should surface these crashes searches by attempting to search the shard.
Additionally I add logging so we can notice when this happens. I didn't add a metric since this is the sort of thing that I think is so rare we would never think to check the metric (but may notice logs).
Note: I used the slightly tricky invariant that repos being nil means error. If the shard is actually empty (eg all repos tombstoned) then we still correctly apply the optimization. In practice having an empty shard shouldn't really happen so I'm open to just treating empty repos list as something we have to search.