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][transaction] avoid too many ServiceUnitNotReadyException for transaction buffer handler #14894

Conversation

codelipenghui
Copy link
Contributor

@codelipenghui codelipenghui commented Mar 26, 2022

Motivation

  1. Added max concurrent request limitation for transaction buffer client
  2. Add the request to the pending request queue after reaching the concurrent request limitation
  3. Avoid duplicated lookup cache invalidation

Documentation

Check the box below or label this PR directly (if you have committer privilege).

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@codelipenghui codelipenghui self-assigned this Mar 26, 2022
@codelipenghui codelipenghui added area/transaction type/bug The PR fixed a bug or issue reported a bug labels Mar 26, 2022
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 26, 2022
@codelipenghui codelipenghui added release/2.9.3 release/2.10.1 and removed doc-not-needed Your PR changes do not impact docs labels Mar 26, 2022
@codelipenghui codelipenghui added this to the 2.11.0 milestone Mar 26, 2022
@github-actions
Copy link

@codelipenghui:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@Anonymitaet Anonymitaet added doc-not-needed Your PR changes do not impact docs and removed doc-label-missing labels Mar 28, 2022
@codelipenghui
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui marked this pull request as ready for review March 30, 2022 11:36
Copy link
Contributor

@congbobo184 congbobo184 left a comment

Choose a reason for hiding this comment

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

LGTM! left some comments

@@ -87,7 +96,18 @@ public TransactionBufferHandlerImpl(PulsarClient pulsarClient,
long requestId = requestIdGenerator.getAndIncrement();
ByteBuf cmd = Commands.newEndTxnOnPartition(requestId, txnIdLeastBits, txnIdMostBits,
topic, action, lowWaterMark);
return endTxn(requestId, topic, cmd, cb);

try {
Copy link
Contributor

Choose a reason for hiding this comment

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

this try catch can be deleted, below all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lookupCache.get(topic) will throw ExecutionException which means some errors happened in the lookup cache, we need to catch the exception and invalidate the cache.

REQUEST_CREDITS_UPDATER.incrementAndGet(this);
}
} else {
checkPendingRequests();
Copy link
Contributor

Choose a reason for hiding this comment

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

only continue; is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch!

response.getError());
cache.invalidate(op.topic);
op.cb.completeExceptionally(ClientCnx.getPulsarClientException(response.getError(), response.getMessage()));
} catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

does we need this try catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just want to add an error log if there are some exceptions when completing the callback, the final block ensure the onResponse() can be complete.

@codelipenghui codelipenghui force-pushed the penghui/transaction_buffer_handler_permits branch from 515a987 to 45aed4e Compare March 30, 2022 15:46
Copy link
Contributor

@gaoran10 gaoran10 left a comment

Choose a reason for hiding this comment

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

LGTM

@codelipenghui codelipenghui force-pushed the penghui/transaction_buffer_handler_permits branch from 45aed4e to 9b109db Compare March 31, 2022 01:03
…ansaction buffer handler

1.Added max outstanding requests limit
2.Add the request to pending request after reach the max outstanding requests
3.Avoid duplicated lookup cache invalidation
@codelipenghui codelipenghui force-pushed the penghui/transaction_buffer_handler_permits branch from 9c03a0f to b9f1b79 Compare March 31, 2022 13:49
@codelipenghui codelipenghui merged commit 384c528 into apache:master Apr 1, 2022
@codelipenghui codelipenghui deleted the penghui/transaction_buffer_handler_permits branch April 1, 2022 05:43
codelipenghui added a commit that referenced this pull request Apr 1, 2022
…ansaction buffer handler (#14894)

1. Added max concurrent request limitation for transaction buffer client
2. Add the request to the pending request queue after reaching the concurrent request limitation
3. Avoid duplicated lookup cache invalidation

(cherry picked from commit 384c528)
@codelipenghui codelipenghui added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label Apr 12, 2022
codelipenghui added a commit that referenced this pull request Apr 19, 2022
…ansaction buffer handler (#14894)

### Motivation

1. Added max concurrent request limitation for transaction buffer client
2. Add the request to the pending request queue after reaching the concurrent request limitation
3. Avoid duplicated lookup cache invalidation

(cherry picked from commit 384c528)
Nicklee007 pushed a commit to Nicklee007/pulsar that referenced this pull request Apr 20, 2022
…ansaction buffer handler (apache#14894)

### Motivation

1. Added max concurrent request limitation for transaction buffer client
2. Add the request to the pending request queue after reaching the concurrent request limitation
3. Avoid duplicated lookup cache invalidation
@codelipenghui codelipenghui restored the penghui/transaction_buffer_handler_permits branch May 17, 2022 01:19
@codelipenghui codelipenghui deleted the penghui/transaction_buffer_handler_permits branch May 17, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/transaction cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.9.3 release/2.10.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants