-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Use mergeBuffer instead of processingBuffer in parallelCombiner #5634
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
Merged
gianm
merged 10 commits into
apache:master
from
jihoonson:merge-buffer-for-parallel-combiner
Apr 28, 2018
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
091078c
Use mergeBuffer instead of processingBuffer in parallelCombiner
jihoonson 5d62a23
Merge branch 'master' of github.com:druid-io/druid into merge-buffer-…
jihoonson 330e9a4
Fix test
jihoonson a8c9f56
address comments
jihoonson ebaf932
fix test
jihoonson de05ede
Fix test
jihoonson 742658d
Update comment
jihoonson a854d6b
address comments
jihoonson f4eb33c
fix build
jihoonson ef81841
Fix test failure
jihoonson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,7 +52,7 @@ public static long leakedResources() | |
| @SuppressWarnings("unused") | ||
| private final Cleaner cleaner; | ||
|
|
||
| ReferenceCountingResourceHolder(final T object, final Closeable closer) | ||
| public ReferenceCountingResourceHolder(final T object, final Closeable closer) | ||
| { | ||
| this.object = object; | ||
| this.closer = closer; | ||
|
|
@@ -64,6 +64,10 @@ public static <T extends Closeable> ReferenceCountingResourceHolder<T> fromClose | |
| return new ReferenceCountingResourceHolder<>(object, object); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the resource with an initial reference count of 1. More references can be added by | ||
| * calling {@link #increment()}. | ||
| */ | ||
| @Override | ||
| public T get() | ||
| { | ||
|
|
@@ -73,6 +77,13 @@ public T get() | |
| return object; | ||
| } | ||
|
|
||
| /** | ||
| * Increments the reference count by 1 and returns a {@link Releaser}. The returned {@link Releaser} is used to | ||
| * decrement the reference count when the caller no longer needs the resource. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should include wording like:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. |
||
| * | ||
| * {@link Releaser}s are not thread-safe. If multiple threads need references to the same holder, they should | ||
| * each acquire their own {@link Releaser}. | ||
| */ | ||
| public Releaser increment() | ||
| { | ||
| while (true) { | ||
|
|
@@ -103,6 +114,9 @@ public void close() | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Decrements the reference count by 1. If it reaches to 0, then closes {@link #closer}. | ||
| */ | ||
| @Override | ||
| public void close() | ||
| { | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has a buffer leak (and it looks like the old code had the leak too, and so does
pollObjects). If eitherpollObjectsortakeObjectsis interrupted while it's waiting for more objects to become available, then the objects popped fromobjectsare not returned to the pool - they are lost.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you elaborate more on how resource leak occurs on interruption?
The implementation of
takeBatchisand
InterruptedExceptioncan be thrown atlock.lockInterruptibly()andnotEnough.await().list.add(objects.pop())is called only when there are enough number of available objects.wrapObject()also doesn't check the interruption state, so objects should be wrapped oncetakeObjects()returns them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you're right, as long as nothing involved checks interrupts:
list.add,objects.pop,wrapObject, etc. It looks like that is the case so there is no leak. Nevermind.