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

Make sure afterBulk is always called in BulkProcessor #6495

Closed
wants to merge 6 commits into from

Conversation

javanna
Copy link
Member

@javanna javanna commented Jun 13, 2014

Java API: Make sure afterBulk is always called in BulkProcessor.

Also strenghtened BulkProcessorTests by adding randomizations to existing tests and new tests for concurrent request.

Closes #5038

@javanna javanna added the bug label Jun 13, 2014
@javanna javanna self-assigned this Jun 13, 2014
@@ -309,13 +311,17 @@ public void onFailure(Throwable e) {
success = true;
} catch (InterruptedException e) {
Thread.interrupted();
//this doesn't seem right, we effectively call afterBulk without having called beforeBulk?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should also check if we called it though?

Copy link
Member Author

Choose a reason for hiding this comment

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

I might be wrong...but InterruptedException can only be thrown in semaphore.acquire, which is before beforeBulk gets called. IMO we should just remove this line, that's why I added the comment...

Copy link
Contributor

Choose a reason for hiding this comment

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

yea makes sense or we move the beforeBulk before the semaphore which might make more sense since we want to keep the critical section as small as possible?

Copy link
Member Author

Choose a reason for hiding this comment

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

I like the idea of moving the beforeBulk up one line. This removes the need for the beforeCalled variable as well. Pushed a new commit.

@s1monw
Copy link
Contributor

s1monw commented Jun 13, 2014

added a small comment... otherwise lgtm

@javanna
Copy link
Member Author

javanna commented Jun 13, 2014

Updated according to review, also added a commit to make sure we don't call afterBulk twice in the blocking case.

@kimchy
Copy link
Member

kimchy commented Jun 13, 2014

LGTM

return multiGetRequestBuilder;
}

private static void checkResponseItems(List<BulkItemResponse> bulkItemResponses, String index, String type, int numDocs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe rename those methods to assert* as this is what they do... same with the next one

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, will change that!

@spinscale
Copy link
Contributor

LGTM

Also strenghtened BulkProcessorTests by adding randomizations to existing tests and new tests for concurrent requests and expcetions

Closes elastic#5038
Moved listener.beforeBulk up one line, before sempahore.acquire. This also removes the need for the beforeCalled boolean variable.
Also remove needless test method parameters
@javanna javanna removed the review label Jun 13, 2014
@javanna
Copy link
Member Author

javanna commented Jun 13, 2014

Merged

@clintongormley clintongormley added the :Core/Infra/Transport API Transport client API label Jun 7, 2015
@clintongormley clintongormley changed the title Java API: Make sure afterBulk is always called in BulkProcessor Make sure afterBulk is always called in BulkProcessor Jun 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Java API: BulkProcessor does not call afterBulk when bulk throws eg NoNodeAvailableException
5 participants