Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where data would sometimes not get loaded into cache after successful read #1524

Merged
merged 5 commits into from
Apr 2, 2019

Conversation

richardartoul
Copy link
Contributor

@richardartoul richardartoul commented Apr 2, 2019

This bug had no impact on correctness, but could impact performance by preventing blocks for series that weren't already in memory from being added to the cache after being read from disk.

Bug was introduced by #1421

Basically even when there are no encoded tags, we wrapped the bytes into a checked.Bytes. The retriever would see that the encoded tags weren't nil and try to put them into a tag decoder. The tag decoder would attempt to read nil bytes and return an error which would prevent a new shard entry from being created for items that were recently read and needed to be put in the cache.

This P.R fixes the issue by performing a length test in the retriever so even if it receives checked.Bytes with zero length it will ignore it AND it changes the seek logic to only pass along a non-nil checked.Bytes if the encoded tags have length larger than zero.

It also adds a regression to test to the retriever to prevent this from happening in the future.

@richardartoul richardartoul changed the title Fix bug where data would sometimes not get loaded into cache after sucessful read Fix bug where data would sometimes not get loaded into cache after successful read Apr 2, 2019
@@ -299,6 +299,10 @@ func testBlockRetrieverHighConcurrentSeeks(t *testing.T, shouldCacheShardIndices
require.True(t, ok, fmt.Sprintf("expected %s to be retrieved, but it was not", id))

expectedTags := ident.NewTags(testTagsFromTestID(id)...)
if !tags.Equal(expectedTags) {
fmt.Println("expected: ", len(expectedTags.Values()))
fmt.Println("actual: ", len(tags.Values()))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a message instead of using fmt.Prints?

i.e.

require.True(t, tags.Equal(expectedTags), 
	fmt.Sprintf("expectedNumTags=%d, actualNumTags=%d", len(expectedTags.Values()), len(tags.Values()))

Copy link
Collaborator

@robskillington robskillington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@richardartoul richardartoul merged commit 8d634d5 into master Apr 2, 2019
@richardartoul richardartoul deleted the ra/only-decode-tags-if-exist branch April 2, 2019 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants