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
[FLINK-13059][Cassandra Connector] Release Semaphore correctly on Exception in send() #8967
Conversation
Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community Automated ChecksLast check on commit 811a803 (Fri Sep 06 09:08:52 UTC 2019) Warnings:
Mention the bot in a comment to re-run the automated checks. Review Progress
Please see the Pull Request Review Guide for a full explanation of the review process. The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commandsThe @flinkbot bot supports the following commands:
|
thanks for your contribution, could you please rebase the latest master and let the Travis build passed? |
…t() also for flush
18b9bf2
to
7fe8595
Compare
I rebased on master, and the Travis build seem to have passed (even though Github is still indicating checks failed). Let me know if I should do anything additional. |
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.
thanks for the rebasing, I just left a little comment.
Currently, we rely on the build status update by @flinkbot
private void flush() { | ||
semaphore.acquireUninterruptibly(config.getMaxConcurrentRequests()); | ||
private void flush() throws InterruptedException, TimeoutException { | ||
if (!semaphore.tryAcquire(config.getMaxConcurrentRequests(), config.getMaxConcurrentRequestsTimeout().toMillis(), TimeUnit.MILLISECONDS)) { |
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.
Do you think we should refactor the tryAcquire()
function to tryAcquire(int permits)
so that we can reuse it here?
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.
Yes, good idea. I will push an additional commit with this refactor.
@@ -140,10 +146,15 @@ protected Session createSession() { | |||
public abstract ListenableFuture<V> send(IN value); | |||
|
|||
private void tryAcquire() throws InterruptedException, TimeoutException { |
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.
As this function is private, do we still need to keep it? or just call tryAcquire(int permits)
directly in invoke
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.
Guess it is a matter of style; I removed the overloaded function, and just call tryAcquire(1)
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.
LGTM now, we need to wait for some committer for a final pass.
What is the purpose of the change
Release the MaxConcurrentRequests Semaphore correctly, if an exception happens in send(). This should make flush() not deadlock, but just in case: make flush timeout controllable by MaxConcurrentRequestsTimeout.
Brief change log
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
@Public(Evolving)
: noDocumentation