You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/05/04 08:29:21 UTC
[GitHub] [pulsar] liangyepianzhou opened a new pull request, #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
liangyepianzhou opened a new pull request, #15424:
URL: https://github.com/apache/pulsar/pull/15424
Master Issue: [#15423](https://github.com/apache/pulsar/issues/15423)
### Motivation & Modification
Details can be found at https://github.com/apache/pulsar/issues/15423.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
*(Please pick either of the following options)*
This change is a trivial rework / code cleanup without any test coverage.
*(or)*
This change is already covered by existing tests, such as *(please describe tests)*.
*(or)*
This change added tests and can be verified as follows:
*(example:)*
- *Added integration tests for end-to-end deployment with large payloads (10MB)*
- *Extended integration test for recovery after broker failure*
### Does this pull request potentially affect one of the following parts:
*If `yes` was chosen, please highlight the changes*
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API: (yes / no)
- The schema: (yes / no / don't know)
- The default values of configurations: (yes / no)
- The wire protocol: (yes / no)
- The rest endpoints: (yes / no)
- The admin cli options: (yes / no)
- Anything that affects deployment: (yes / no / don't know)
### Documentation
Check the box below or label this PR directly.
Need to update docs?
- [ ] `doc-required`
(Your PR needs to update docs and you will update later)
- [ ] `no-need-doc`
(Please explain why)
- [ ] `doc`
(Your PR contains doc changes)
- [ ] `doc-added`
(Docs have been already added)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r868158800
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -971,4 +972,21 @@ public void testPendingAckMarkDeletePosition() throws Exception {
Integer.parseInt(lastConfirmedEntry[1]) - 2);
});
}
+
+ @Test
+ public void testTBLowWaterMark() throws Exception {
Review Comment:
OK, the test is very much needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r867621397
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -971,4 +972,21 @@ public void testPendingAckMarkDeletePosition() throws Exception {
Integer.parseInt(lastConfirmedEntry[1]) - 2);
});
}
+
+ @Test
+ public void testTBLowWaterMark() throws Exception {
Review Comment:
I have move the test from `TransactionTest` to `TransactionLowWaterMarkTest`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r867622368
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -240,6 +244,13 @@ public CompletableFuture<Void> checkIfTBRecoverCompletely(boolean isTxnEnabled)
@Override
public CompletableFuture<Position> appendBufferToTxn(TxnID txnId, long sequenceId, ByteBuf buffer) {
CompletableFuture<Position> completableFuture = new CompletableFuture<>();
+ Long lowWaterMark = lowWaterMarks.get(txnId.getMostSigBits());
+ if (lowWaterMark != null && lowWaterMark >= txnId.getLeastSigBits()) {
+ completableFuture.completeExceptionally(new TransactionBufferException
+ .TransactionNotFoundException("Transaction [" + txnId + "] has been ended. "
+ + "Please use a new transaction to send message."));
+ return completableFuture;
Review Comment:
I have change exception from `TransactionNotFoundException` to `NotAllowedException`.
And the `NotAllowedException` is not only used to `Exceed maximum message size`, so i change the `recoverNotAllowedError` to make the expression of the log clearer.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r868158800
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -971,4 +972,21 @@ public void testPendingAckMarkDeletePosition() throws Exception {
Integer.parseInt(lastConfirmedEntry[1]) - 2);
});
}
+
+ @Test
+ public void testTBLowWaterMark() throws Exception {
Review Comment:
OK, the test is very much needed. I have add it and fix the exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r867603362
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -971,4 +972,21 @@ public void testPendingAckMarkDeletePosition() throws Exception {
Integer.parseInt(lastConfirmedEntry[1]) - 2);
});
}
+
+ @Test
+ public void testTBLowWaterMark() throws Exception {
Review Comment:
We already have end to end test at `TransactionLowWaterMarkTest`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou closed pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou closed pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
URL: https://github.com/apache/pulsar/pull/15424
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r865998560
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -275,6 +286,7 @@ public CompletableFuture<TransactionBufferReader> openTransactionBufferReader(Tx
@Override
public CompletableFuture<Void> commitTxn(TxnID txnID, long lowWaterMark) {
+ lowWaterMarks.compute(txnID.getMostSigBits(), (k, v) -> lowWaterMark);
Review Comment:
Good suggestion, I think you are right. The method `endTxnInTransactionBuffer` is asynchronous, we can not grantee the order of committed operation .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] github-actions[bot] commented on pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#issuecomment-1117053432
@liangyepianzhou:Thanks for providing doc info!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] Technoboy- commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
Technoboy- commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r865519434
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -240,6 +244,13 @@ public CompletableFuture<Void> checkIfTBRecoverCompletely(boolean isTxnEnabled)
@Override
public CompletableFuture<Position> appendBufferToTxn(TxnID txnId, long sequenceId, ByteBuf buffer) {
CompletableFuture<Position> completableFuture = new CompletableFuture<>();
+ if (lowWaterMarks.get(txnId.getMostSigBits()) != null
Review Comment:
Add a local variable for `lowWaterMarks.get(txnId.getMostSigBits())`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] github-actions[bot] commented on pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#issuecomment-1117053299
@liangyepianzhou:Thanks for your contribution. For this PR, do we need to update docs?
(The [PR template contains info about doc](https://github.com/apache/pulsar/blob/master/.github/PULL_REQUEST_TEMPLATE.md#documentation), which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] congbobo184 merged pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
congbobo184 merged PR #15424:
URL: https://github.com/apache/pulsar/pull/15424
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r868058689
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -971,4 +972,21 @@ public void testPendingAckMarkDeletePosition() throws Exception {
Integer.parseInt(lastConfirmedEntry[1]) - 2);
});
}
+
+ @Test
+ public void testTBLowWaterMark() throws Exception {
Review Comment:
@liangyepianzhou I mean an end-to-end test for the new change. If we already have a test for this part, why the test can get passed without this fix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
poorbarcode commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r865962577
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -275,6 +286,7 @@ public CompletableFuture<TransactionBufferReader> openTransactionBufferReader(Tx
@Override
public CompletableFuture<Void> commitTxn(TxnID txnID, long lowWaterMark) {
+ lowWaterMarks.compute(txnID.getMostSigBits(), (k, v) -> lowWaterMark);
Review Comment:
Hi @liangyepianzhou Shall we compare the `old lowWaterMark` with the `new lowWaterMark`, make sure the `new lowWaterMark` is bigger than the `old lowWaterMark`.
Maybe it's unnecessary, just make a suggestion
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] poorbarcode commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
poorbarcode commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r865962577
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -275,6 +286,7 @@ public CompletableFuture<TransactionBufferReader> openTransactionBufferReader(Tx
@Override
public CompletableFuture<Void> commitTxn(TxnID txnID, long lowWaterMark) {
+ lowWaterMarks.compute(txnID.getMostSigBits(), (k, v) -> lowWaterMark);
Review Comment:
Hi @liangyepianzhou Shall we compare the `old lowWaterMark` with the `new lowWaterMark`, make sure the `new lowWaterMark` is bigger than the `old lowWaterMark`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r867595749
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -240,6 +244,13 @@ public CompletableFuture<Void> checkIfTBRecoverCompletely(boolean isTxnEnabled)
@Override
public CompletableFuture<Position> appendBufferToTxn(TxnID txnId, long sequenceId, ByteBuf buffer) {
CompletableFuture<Position> completableFuture = new CompletableFuture<>();
+ Long lowWaterMark = lowWaterMarks.get(txnId.getMostSigBits());
+ if (lowWaterMark != null && lowWaterMark >= txnId.getLeastSigBits()) {
+ completableFuture.completeExceptionally(new TransactionBufferException
+ .TransactionNotFoundException("Transaction [" + txnId + "] has been ended. "
+ + "Please use a new transaction to send message."));
+ return completableFuture;
Review Comment:
Please check here https://github.com/apache/pulsar/blob/4f53e8eedc8aca406f60ab4c1f7bc11577a6bf20/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L2977-L2984
The TransactionNotFoundException will be wrapped with ManagedLedgerException. It should be wrapped by PersistenceException directly?
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/transaction/TransactionTest.java:
##########
@@ -971,4 +972,21 @@ public void testPendingAckMarkDeletePosition() throws Exception {
Integer.parseInt(lastConfirmedEntry[1]) - 2);
});
}
+
+ @Test
+ public void testTBLowWaterMark() throws Exception {
Review Comment:
Please also add an end to end test to make sure the client-side can handle the new exception well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui commented on a diff in pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on code in PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#discussion_r868065508
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TopicTransactionBuffer.java:
##########
@@ -240,6 +244,13 @@ public CompletableFuture<Void> checkIfTBRecoverCompletely(boolean isTxnEnabled)
@Override
public CompletableFuture<Position> appendBufferToTxn(TxnID txnId, long sequenceId, ByteBuf buffer) {
CompletableFuture<Position> completableFuture = new CompletableFuture<>();
+ Long lowWaterMark = lowWaterMarks.get(txnId.getMostSigBits());
+ if (lowWaterMark != null && lowWaterMark >= txnId.getLeastSigBits()) {
+ completableFuture.completeExceptionally(new TransactionBufferException
+ .TransactionNotFoundException("Transaction [" + txnId + "] has been ended. "
+ + "Please use a new transaction to send message."));
+ return completableFuture;
Review Comment:
But the `NotAllowedException` will also be wrapped by `ManagedLedgerException` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] liangyepianzhou commented on pull request #15424: [PIP-163][Txn]Add lowWaterMark check before appending entry to TB
Posted by GitBox <gi...@apache.org>.
liangyepianzhou commented on PR #15424:
URL: https://github.com/apache/pulsar/pull/15424#issuecomment-1124996672
/pulsarbot run-failure-checks
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org