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

[FLINK-13059][Cassandra Connector] Release Semaphore correctly on Exception in send() #8967

Merged
merged 4 commits into from Sep 3, 2019

Conversation

mchro
Copy link
Contributor

@mchro mchro commented Jul 3, 2019

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

  • Release Semaphore correctly on Exception in send()
  • Use getMaxConcurrentRequestsTimeout() also for flush

Verifying this change

This change added tests and can be verified as follows:

  • Added unit test that validates semaphore released if Exception in send(); test fails before change.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: no
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

flinkbot commented Jul 3, 2019

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 811a803 (Fri Sep 06 09:08:52 UTC 2019)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

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 commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@klion26
Copy link
Member

klion26 commented Jul 5, 2019

thanks for your contribution, could you please rebase the latest master and let the Travis build passed?

@zentol
Copy link
Contributor

zentol commented Jul 6, 2019

CI report for commit 18b9bf2: FAILURE Travis

@mchro mchro force-pushed the cassandra-semaphore-leak branch from 18b9bf2 to 7fe8595 Compare July 6, 2019 13:01
@flinkbot
Copy link
Collaborator

flinkbot commented Jul 7, 2019

CI report for commit 7fe8595: SUCCESS Build

@mchro
Copy link
Contributor Author

mchro commented Jul 15, 2019

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.

@flinkbot
Copy link
Collaborator

flinkbot commented Jul 15, 2019

CI report:

Copy link
Member

@klion26 klion26 left a 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)) {
Copy link
Member

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?

Copy link
Contributor Author

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 {
Copy link
Member

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

Copy link
Contributor Author

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)

Copy link
Member

@klion26 klion26 left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants