asafm commented on code in PR #21114:
URL: https://github.com/apache/pulsar/pull/21114#discussion_r1349691466


##########
pip/pip-298.md:
##########
@@ -1,28 +1,106 @@
-## Background
+# Background
 
-In the implementation of the Pulsar Transaction, each topic is configured with 
a `Transaction Buffer` to prevent consumers from reading uncommitted messages, 
which are invisible until the transaction is committed. Transaction Buffer 
works with Position (maxReadPosition) and `TxnID` Set (aborts). The broker only 
dispatches messages, before the maxReadPosition, to the consumers. When the 
broker dispatches the messages before maxReadPosition to the consumer, the 
messages sent by aborted transactions will get filtered by the Transaction 
Buffer.
+In the implementation of the Pulsar Transaction, each topic is configured with 
a `Transaction Buffer` to prevent
+consumers from reading uncommitted messages, which are invisible until the 
transaction is committed. Transaction Buffer
+works with Position (maxReadPosition) and `TxnID` Set (aborts). The broker 
only dispatches messages, before the
+maxReadPosition, to the consumers. When the broker dispatches the messages 
before maxReadPosition to the consumer, the
+messages sent by aborted transactions will get filtered by the Transaction 
Buffer.
 
-## Motivation
+# Motivation
 
-Currently, Pulsar transactions do not have configurable isolation levels. By 
introducing isolation level configuration for consumers, we can enhance the 
flexibility of Pulsar transactions.
+Currently, Pulsar transactions do not have configurable isolation levels. By 
introducing isolation level configuration
+for consumers, we can enhance the flexibility of Pulsar transactions.
 
-## Goal
+Let's consider an example:
 
-### In Scope
+**System**: Financial Transaction System
 
-Implement Read Committed and Read Uncommitted isolation levels for Pulsar 
transactions.Allow consumers to configure isolation levels during the building 
process.
+**Operations**: Large volume of deposit and withdrawal operations, a
+small number of transfer operations.
 
-### Out of Scope
+**Roles**:
+
+- **Client A1**
+- **Client A2**
+- **User Account B1**
+- **User Account B2**
+- **Request Topic C**
+- **Real-time Monitoring System D**
+- **Business Processing System E**
+
+**Client Operations**:
+
+- **Withdrawal**: Client A1 decreases the deposit amount from User
+  Account B1 or B2.
+- **Deposit**: Client A1 increases the deposit amount in User Account B1 or B2.
+- **Transfer**: Client A2 decreases the deposit amount from User
+  Account B1 and increases it in User Account B2. Or vice versa.
+
+**Real-time Monitoring System D**: Obtains the latest data from
+Request Topic C as quickly as possible to monitor transaction data and
+changes in bank reserves in real-time. This is necessary for the
+timely detection of anomalies and real-time decision-making.
+
+**Business Processing System E**: Reads data from Request Topic C,
+then actually operates User Accounts B1, B2.
+
+**User Scenario**: Client A1 sends a large number of deposit and
+withdrawal requests to Request Topic C. Client A2 writes a small
+number of transfer requests to Request Topic C.
+
+In this case, Business Processing System E needs a read-committed
+isolation level to ensure operation consistency and Exactly Once
+semantics. The real-time monitoring system does not care if a small
+number of transfer requests are incomplete (dirty data). What it
+cannot tolerate is a situation where a large number of deposit and
+withdrawal requests cannot be presented in real time due to a small
+number of transfer requests (the current situation is that uncommitted
+transaction messages can block the reading of committed transaction
+messages).
+
+In this case, it is necessary to set different isolation levels for
+different consumers/subscriptions.
+The uncommitted transactions do not impact actual users' bank accounts.
+Business Processing System E only reads committed transactional
+messages and operates users' accounts. It needs Exactly-once semantic.
+Real-time Monitoring System D reads uncommitted transactional
+messages. It does not need Exactly-once semantic.
+
+They use different subscriptions and choose different isolation
+levels. One needs transaction, one does not.
+In general, multiple subscriptions of the same topic do not all
+require transaction guarantees.
+Some want low latency without the exact-once semantic guarantee, and
+some must require the exactly-once guarantee.
+We just provide a new option for different subscriptions.
+
+# Goal
+
+## In Scope
+
+Implement Read Committed and Read Uncommitted isolation levels for Pulsar 
transactions. Allow consumers to configure
+isolation levels during the building process.
+
+## Out of Scope
 
 None.
 
-## API Changes
+# High Level Design
+
+Add a configuration 'subscriptionIsolationLevel' in the consumer builder to 
allow users to choose different transaction

Review Comment:
   @codelipenghui Do we keep a table of client features each SDK needs to 
implement?



##########
pip/pip-298.md:
##########
@@ -93,13 +176,22 @@ Modify the transaction buffer and dispatching mechanisms 
to handle messages base
 
 In order to achieve the above goals, the following modifications need to be 
made:
 
-- Determine in the `readMoreEntries` method of Dispatchers such as 
`PersistentDispatcherSingleActiveConsumer` and 
`PersistentDispatcherMultipleConsumers`:
+- Determine in the `readMoreEntries` method of Dispatchers such as 
`PersistentDispatcherSingleActiveConsumer`
+  and `PersistentDispatcherMultipleConsumers`:
+
+  - If Subscription.isolationLevel == ReadCommitted, then MaxReadPosition = 
topic.getMaxReadPosition(), that is,
+    transactionBuffer.getMaxReadPosition()
+
+  - If Subscription.isolationLevel == ReadUnCommitted, then MaxReadPosition = 
PositionImpl.LATEST
 
-    - If Subscription.isolationLevel == ReadCommitted, then MaxReadPosition = 
topic.getMaxReadPosition(), that is, transactionBuffer.getMaxReadPosition()
+- Add a new metrics `subscriptionIsolationLevel` in `SubscriptionStatsImpl`.
 
-    - If Subscription.isolationLevel == ReadUnCommitted, then MaxReadPosition 
= PositionImpl.LATEST
+# Monitoring

Review Comment:
   Looks good



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to