From d09f389a04645fd600da7235c8635ae2395dab95 Mon Sep 17 00:00:00 2001 From: ruihongzhou Date: Fri, 15 Dec 2023 19:34:42 +0800 Subject: [PATCH 1/3] [improve][pip] PIP-325: Add command to abort transaction --- pip/pip-325.md | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 pip/pip-325.md diff --git a/pip/pip-325.md b/pip/pip-325.md new file mode 100644 index 0000000000000..b771fb6bd4402 --- /dev/null +++ b/pip/pip-325.md @@ -0,0 +1,93 @@ +# Background knowledge + +In the current implementation of Pulsar Transaction, Topics ensure that consumers do not read messages belonging +to uncommitted transactions through the Transaction Buffer. Within the Transaction Buffer, a Position (`maxReadPosition`) +is maintained, as well as a set of aborted transactions (`aborts`). The `maxReadPosition` controls the maximum message +position that the broker can read, and it is adjusted to the position just before the first message of the first ongoing +transaction when a transaction is committed or aborted. Before distributing messages to consumers, the broker filters out +messages that belong to already aborted transactions using the `aborts` set. + +# Motivation +If we have a stuck transaction, then the transactions after this one cannot be consumed by the consumer +even if they have been committed. The consumer will be stuck until the stuck transaction is aborted due to timeout, +and then it will continue to consume messages. Therefore, we need to add a command to allow cluster administrators +to proactively abort transaction. + +# Goals + +## In Scope + +Introduce a new API for aborting transactions, allowing administrators to proactively abort transaction. + +## Out of Scope + +None. + + +# High Level Design + +Introduce a new API for aborting transactions, allowing administrators to proactively abort transaction. + +# Detailed Design + +## Design & Implementation Details + +Introduce a new API for aborting transactions, allowing administrators to proactively abort transaction. + +## Public-facing Changes + +### Public API +Add a new API to abort transaction: +``` + /** + * Abort a transaction. + * + * @param txnID the txnId + */ + void abortTransaction(TxnID txnID) throws PulsarAdminException; + + /** + * Asynchronously Abort a transaction. + * + * @param txnID the txnId + */ + CompletableFuture abortTransactionAsync(TxnID txnID); +``` +``` +admin.transactions().abortTransaction(txnID); +``` + +### Binary protocol + +### Configuration + +### CLI +Add a command to abort transaction: +``` +pulsar-admin transactions abort-transaction --most-sig-bits 1 --least-sig-bits 2 +``` +### Metrics +None. + +# Monitoring +None. + +# Security Considerations + +# Backward & Forward Compatibility + +## Revert + +## Upgrade + +# Alternatives + +# General Notes + +# Links + + +* Mailing List discussion thread: +* Mailing List voting thread: From 5a2b25b39d0f4b52be5b47535691b0e2ea6185da Mon Sep 17 00:00:00 2001 From: ruihongzhou Date: Tue, 2 Jan 2024 11:11:40 +0800 Subject: [PATCH 2/3] optimize --- pip/pip-325.md | 1 + 1 file changed, 1 insertion(+) diff --git a/pip/pip-325.md b/pip/pip-325.md index b771fb6bd4402..8796386751904 100644 --- a/pip/pip-325.md +++ b/pip/pip-325.md @@ -73,6 +73,7 @@ None. None. # Security Considerations +The transaction owner and super user can access the admin API to abort the transaction. # Backward & Forward Compatibility From 0f2d7e1a1c134230fd37d636f24a3a6672c63590 Mon Sep 17 00:00:00 2001 From: ruihongzhou Date: Thu, 11 Jan 2024 10:25:49 +0800 Subject: [PATCH 3/3] update --- pip/pip-325.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pip/pip-325.md b/pip/pip-325.md index 8796386751904..44d1aebc6a4eb 100644 --- a/pip/pip-325.md +++ b/pip/pip-325.md @@ -90,5 +90,5 @@ The transaction owner and super user can access the admin API to abort the trans -* Mailing List discussion thread: -* Mailing List voting thread: +* Mailing List discussion thread: https://lists.apache.org/thread/ssgngyrlgx36zvygvsd5b2dm5q6krn0f +* Mailing List voting thread: https://lists.apache.org/thread/kp9w4d8drngomx1mdof0203ybgfmvtty