state: remove duplicate tableCheck indexes #9796
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 PR uses a new pattern (see
agent/consul/state/indexer.go
) for defining memdb indexes in the state store.By using this pattern we are able to remove one of the indexes on the check table. The generic index did not behave the way we wanted, which forced us to create a second index. Now we can use a single index because we add the blank string value as part of the index.
Since each section of the index is null terminated, there is no ambiguity. Node checks will have two sequential null bytes at the end, but that is ok.
This PR also makes the new function signature for indexFromObject match that of indexFromQuery by using errors as values. This will allow us to use the same function for both sets of operations (queries and insert/delete).
It also adds an indexBuilder which can be used instead of a bytes.Buffer to add null terminators, and makes the index building a little less verbose.