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 annotation pooling #1476

Merged
merged 14 commits into from
Mar 20, 2019
Merged

Fix annotation pooling #1476

merged 14 commits into from
Mar 20, 2019

Conversation

richardartoul
Copy link
Contributor

@richardartoul richardartoul commented Mar 19, 2019

Fixes a pooling bug that was caused by returning annotations to the apache thrift byte pool once RPCs had completed. This was problematic because the commit log still had a reference to them, as well as the shard insert queue if we were inserting a new series asynchronously.

@codecov
Copy link

codecov bot commented Mar 19, 2019

Codecov Report

Merging #1476 into master will decrease coverage by 9.8%.
The diff coverage is 90%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1476      +/-   ##
=========================================
- Coverage    70.9%     61%    -9.9%     
=========================================
  Files         841     612     -229     
  Lines       71895   56313   -15582     
=========================================
- Hits        51000   34376   -16624     
- Misses      17555   19287    +1732     
+ Partials     3340    2650     -690
Flag Coverage Δ
#aggregator 76.1% <ø> (-6.3%) ⬇️
#cluster 85.9% <ø> (+0.1%) ⬆️
#collector 54.9% <ø> (-8.8%) ⬇️
#dbnode 64.8% <90%> (-16.1%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 69.8% <ø> (-4.5%) ⬇️
#m3nsch 78% <ø> (+26.8%) ⬆️
#metrics 17.6% <ø> (ø) ⬆️
#msg 75% <ø> (ø) ⬆️
#query 60.2% <ø> (-5.9%) ⬇️
#x 76.6% <ø> (+0.2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 995679e...ea5d9c7. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 19, 2019

Codecov Report

Merging #1476 into master will decrease coverage by 5.1%.
The diff coverage is 84.6%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1476      +/-   ##
=========================================
- Coverage    70.9%   65.8%    -5.2%     
=========================================
  Files         841     657     -184     
  Lines       71895   54023   -17872     
=========================================
- Hits        51000   35550   -15450     
+ Misses      17555   16121    -1434     
+ Partials     3340    2352     -988
Flag Coverage Δ
#aggregator 84.7% <ø> (+2.4%) ⬆️
#cluster 85.6% <ø> (-0.2%) ⬇️
#collector 54.9% <ø> (-8.8%) ⬇️
#dbnode 72.9% <84.6%> (-7.9%) ⬇️
#m3em 57% <ø> (-16.2%) ⬇️
#m3ninx 68.4% <ø> (-5.9%) ⬇️
#m3nsch 78% <ø> (+26.8%) ⬆️
#metrics 17.6% <ø> (ø) ⬆️
#msg 74.9% <ø> (-0.2%) ⬇️
#query 63.8% <ø> (-2.3%) ⬇️
#x 72.4% <ø> (-4%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 995679e...070d88e. Read the comment docs.

@@ -127,4 +131,6 @@ type BatchWriter interface {
unit xtime.Unit,
annotation []byte,
)

SetFinalizeAnnotationFn(f FinalizeAnnotationFn)
Copy link
Collaborator

Choose a reason for hiding this comment

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

how would you feel about changing FinalizeAnnotationFn to FinalizeWriteFn? That way the caller can decide what level of finalization they need (e.g. if they need to do stuff to fields beyond just the annotation)

also nit: add a comment above fn

Copy link
Collaborator

Choose a reason for hiding this comment

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

talked offline: going to leave as is and add a comment explaining the choice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Spoke offline and agreed to leave as is since the lifecycle is already confusing enough without making it more generic

if elem.Datapoint.Annotation != nil {
apachethrift.BytesPoolPut(elem.Datapoint.Annotation)
}
// Don't return the annotations to the pool because they don't
Copy link
Collaborator

Choose a reason for hiding this comment

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

the first sentence in the comment is confusing unless people understand nuances of when IDs are cloned v when retained. much simpler to just rely on the second sentence and say the ownership of the lifecycle for the annotations has been transferred to the BatchWriter.

that said, can we do the same thing for the ID/EncodedTags too? i.e. expect the BatchWriter to clean it up? might cause a minor rise in steady state memory usage but would simplify this code a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed the comment. Spoke offline and decided not to do the ID/EncodedTags thing for performance reasons (more synchronization required by single-threaded commitlog)

}

func TestShardWriteAsyncWithAnnotations(t *testing.T) {
testShardWriteAsync(t, []testWrite{
Copy link
Collaborator

Choose a reason for hiding this comment

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

one more test case - ensure we don't copy the annotation bytes if the series already exists in the shard

Copy link
Collaborator

@prateek prateek left a comment

Choose a reason for hiding this comment

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

LGTM save the pending test

@richardartoul richardartoul merged commit 6e43e28 into master Mar 20, 2019
@richardartoul richardartoul deleted the ra/fix-annotation-pooling branch March 20, 2019 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:db All issues pertaining to dbnode PR: Review Priority High T: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants