You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "liangyepianzhou (via GitHub)" <gi...@apache.org> on 2024/01/15 10:41:47 UTC
Re: [PR] [improve][txn] Add command to abort transaction [pulsar]
liangyepianzhou commented on code in PR #21630:
URL: https://github.com/apache/pulsar/pull/21630#discussion_r1452211207
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v3/AdminApiTransactionTest.java:
##########
@@ -894,6 +897,25 @@ public void testGetPositionStatsInPendingAckStatsFroBatch() throws Exception {
}
+ @Test
+ public void testAbortTransaction() throws Exception {
+ initTransaction(1);
+
+ Transaction transaction = pulsarClient.newTransaction()
+ .withTransactionTimeout(5, TimeUnit.MINUTES).build().get();
+
+ TxnMeta txnMeta = pulsar.getTransactionMetadataStoreService().getTxnMeta(transaction.getTxnID()).get();
+ assertEquals(txnMeta.status(), TxnStatus.OPEN);
+
+ // abort
+ admin.transactions().abortTransaction(transaction.getTxnID());
+ try {
+ pulsar.getTransactionMetadataStoreService().getTxnMeta(transaction.getTxnID()).get();
Review Comment:
```suggestion
pulsar.getTransactionMetadataStoreService().getTxnMeta(transaction.getTxnID()).get();
fail();
```
##########
pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Transactions.java:
##########
@@ -400,4 +400,18 @@ PositionInPendingAckStats getPositionStatsInPendingAck(String topic, String subN
CompletableFuture<PositionInPendingAckStats> getPositionStatsInPendingAckAsync(String topic, String subName,
Long ledgerId, Long entryId,
Integer batchIndex);
+
+ /**
+ * Abort a transaction.
+ *
+ * @param txnID the txnId
+ */
+ void abortTransaction(TxnID txnID) throws PulsarAdminException;
+
+ /**
+ * Asynchronously Abort a transaction.
Review Comment:
```suggestion
* Asynchronously abort a transaction.
```
--
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