From df68dfc6fe800ae5f107666982001659a0cc092f Mon Sep 17 00:00:00 2001 From: hzh0425 <642256541@qq.com> Date: Fri, 6 Oct 2023 16:27:12 +0800 Subject: [PATCH 01/15] Add introduction of transaction isolation level in the txn-advanced-features.md --- docs/txn-advanced-features.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 8819fcf8fba3..67d7b94f432b 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -37,10 +37,29 @@ If you want to enable authentication with transactions, follow the steps below. 2. [Configure authentication](security-overview/#authentication) in a Pulsar client. +## Select transaction isolation level + +In order to enhance the flexibility of pulsar transactions, pulsar transactions support two different isolation levels, the default isolation level is Read Committed: +- READ_COMMITTED, Consumer can only consume all transactional messages which have been committed. +- READ_UNCOMMITTED, Consumer can consume all messages, even transactional messages which have been aborted. + +Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. +This example selects READ_UNCOMMITTED Isolation level in the consumer builder: + +```java +Consumer consumer = client + .newConsumer(Schema.STRING) + .topic("persistent://my-tenant/my-namespace/my-topic") + .subscriptionName("my-subscription") + .subscriptionType(SubscriptionType.Shared) + .subscriptionIsolationLevel(SubscriptionIsolationLevel.READ_COMMITTED) // Adding the isolation level configuration + .subscribe(); +``` + ## Guarantee exactly-once semantics If you want to guarantee exactly-once semantics with transactions, you can [enable message deduplication at the broker, namespace, or topic level](cookbooks-deduplication.md#enable-message-deduplication-at-namespace-or-topic-level). ## Related topics -- To get up quickly, see [Pulsar transactions - Get started](txn-use.md). \ No newline at end of file +- To get up quickly, see [Pulsar transactions - Get started](txn-use.md). From 384084d2ab48297e7f499bdecdb10be48213601b Mon Sep 17 00:00:00 2001 From: hzh0425 <642256541@qq.com> Date: Sat, 7 Oct 2023 21:19:46 +0800 Subject: [PATCH 02/15] Add motivation --- docs/txn-advanced-features.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 67d7b94f432b..3591e170b6e2 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -43,7 +43,12 @@ In order to enhance the flexibility of pulsar transactions, pulsar transactions - READ_COMMITTED, Consumer can only consume all transactional messages which have been committed. - READ_UNCOMMITTED, Consumer can consume all messages, even transactional messages which have been aborted. +For different scenarios, 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(like Real-time monitoring system), and some must require the exactly-once guarantee(like Business Processing System). +Users can freely choose different isolation levels according to different scenarios. + Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. + This example selects READ_UNCOMMITTED Isolation level in the consumer builder: ```java From 66e92acaab287fdb85c42834decf7498c5dbff35 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:35:03 +0300 Subject: [PATCH 03/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 3591e170b6e2..7a0fdeaee8af 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -39,7 +39,7 @@ If you want to enable authentication with transactions, follow the steps below. ## Select transaction isolation level -In order to enhance the flexibility of pulsar transactions, pulsar transactions support two different isolation levels, the default isolation level is Read Committed: +To enhance the flexibility of Pulsar transactions, they support two distinct isolation levels: - READ_COMMITTED, Consumer can only consume all transactional messages which have been committed. - READ_UNCOMMITTED, Consumer can consume all messages, even transactional messages which have been aborted. From 7e0f50942a9759c49df7fb38b9703d76578b1502 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:35:14 +0300 Subject: [PATCH 04/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 7a0fdeaee8af..1848fac78125 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -40,7 +40,7 @@ If you want to enable authentication with transactions, follow the steps below. ## Select transaction isolation level To enhance the flexibility of Pulsar transactions, they support two distinct isolation levels: -- READ_COMMITTED, Consumer can only consume all transactional messages which have been committed. +- `READ_COMMITTED`(default): The consumer can only consume all transactional messages that have been committed. - READ_UNCOMMITTED, Consumer can consume all messages, even transactional messages which have been aborted. For different scenarios, 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 From 88b04db2a8d42842713f99b4c39d362605b64b26 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:35:22 +0300 Subject: [PATCH 05/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 1848fac78125..6210dbb6b8e7 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -41,7 +41,7 @@ If you want to enable authentication with transactions, follow the steps below. To enhance the flexibility of Pulsar transactions, they support two distinct isolation levels: - `READ_COMMITTED`(default): The consumer can only consume all transactional messages that have been committed. -- READ_UNCOMMITTED, Consumer can consume all messages, even transactional messages which have been aborted. +- `READ_UNCOMMITTED`: The consumer can consume all messages, even transactional messages that have been aborted. For different scenarios, 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(like Real-time monitoring system), and some must require the exactly-once guarantee(like Business Processing System). From d2139cc475bc29aa6bc995b90a337027605a3e21 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:35:30 +0300 Subject: [PATCH 06/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 6210dbb6b8e7..5bc1475f35bd 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -49,7 +49,7 @@ Users can freely choose different isolation levels according to different scenar Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. -This example selects READ_UNCOMMITTED Isolation level in the consumer builder: +This example selects `READ_UNCOMMITTED` Isolation level in the consumer builder: ```java Consumer consumer = client From a878ea212a5a40cd7c3246203ccb426b9a4e827f Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:39:07 +0300 Subject: [PATCH 07/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 5bc1475f35bd..fa50b339cc7d 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -44,7 +44,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso - `READ_UNCOMMITTED`: The consumer can consume all messages, even transactional messages that have been aborted. For different scenarios, 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(like Real-time monitoring system), and some must require the exactly-once guarantee(like Business Processing System). +require transaction guarantees. Some want low latency without the exact-once semantic guarantee(like Real-time monitoring system), and some must require the exactly-once guarantee (like Business Processing System). Users can freely choose different isolation levels according to different scenarios. Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. From 997db7d94f568d6bc45ab594c28a4e27e420f299 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:39:36 +0300 Subject: [PATCH 08/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index fa50b339cc7d..58fb501aa9e2 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -44,7 +44,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso - `READ_UNCOMMITTED`: The consumer can consume all messages, even transactional messages that have been aborted. For different scenarios, 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(like Real-time monitoring system), and some must require the exactly-once guarantee (like Business Processing System). +require transaction guarantees. Some want low latency without the exact-once semantic guarantee (like Real-time monitoring system), and some must require the exactly-once guarantee (like Business Processing System). Users can freely choose different isolation levels according to different scenarios. Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. From 49a61b545089359b55f5acb7806b022ec31deba2 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:40:08 +0300 Subject: [PATCH 09/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 58fb501aa9e2..42a4f60ad244 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -44,7 +44,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso - `READ_UNCOMMITTED`: The consumer can consume all messages, even transactional messages that have been aborted. For different scenarios, 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 (like Real-time monitoring system), and some must require the exactly-once guarantee (like Business Processing System). +require transaction guarantees. Some want low latency without the exact-once semantic guarantee (like Real-Time Monitoring System), and some must require the exactly-once guarantee (like Business Processing System). Users can freely choose different isolation levels according to different scenarios. Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. From 04836a9e7a3dbb07e43877d61dd9b9ac0368c45d Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:46:24 +0300 Subject: [PATCH 10/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 42a4f60ad244..20ab87115ff8 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -44,7 +44,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso - `READ_UNCOMMITTED`: The consumer can consume all messages, even transactional messages that have been aborted. For different scenarios, 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 (like Real-Time Monitoring System), and some must require the exactly-once guarantee (like Business Processing System). +require transaction guarantees. Some want low latency without the exact-once semantic guarantee (like a real-time monitoring system), and some must require the exactly-once guarantee (e.g., business processing systems). Users can freely choose different isolation levels according to different scenarios. Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. From 34d5714e71f795274b49b3478f2841e851c3264a Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:48:09 +0300 Subject: [PATCH 11/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 20ab87115ff8..65a34c78630a 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -49,7 +49,7 @@ Users can freely choose different isolation levels according to different scenar Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. -This example selects `READ_UNCOMMITTED` Isolation level in the consumer builder: +In this example, the consumer builder uses the `READ_UNCOMMITTED` isolation level. ```java Consumer consumer = client From 61f7e5925a2b1aec57be6d6eeaca34c2c338448d Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:54:13 +0300 Subject: [PATCH 12/15] Update docs/txn-advanced-features.md [ci skip] --- docs/txn-advanced-features.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 65a34c78630a..2b5dbcae8a3f 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -43,8 +43,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso - `READ_COMMITTED`(default): The consumer can only consume all transactional messages that have been committed. - `READ_UNCOMMITTED`: The consumer can consume all messages, even transactional messages that have been aborted. -For different scenarios, 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 (like a real-time monitoring system), and some must require the exactly-once guarantee (e.g., business processing systems). +For different scenarios, they use different subscriptions and choose different isolation levels. One scenario might require transactions, while another might not. In general, not all subscriptions of the same topic require transaction guarantees. Some want low latency without the exact-once semantic guarantee (like a real-time monitoring system), and some must require the exactly-once guarantee (e.g., business processing systems). Users can freely choose different isolation levels according to different scenarios. Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. From aaf8b6355cba0716055fc66c00335910b005d2c5 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:54:22 +0300 Subject: [PATCH 13/15] Update docs/txn-advanced-features.md [ci skip] --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index 2b5dbcae8a3f..a5b06ce802b8 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -56,7 +56,7 @@ Consumer consumer = client .topic("persistent://my-tenant/my-namespace/my-topic") .subscriptionName("my-subscription") .subscriptionType(SubscriptionType.Shared) - .subscriptionIsolationLevel(SubscriptionIsolationLevel.READ_COMMITTED) // Adding the isolation level configuration + .subscriptionIsolationLevel(SubscriptionIsolationLevel.READ_UNCOMMITTED) // Adding the isolation level configuration .subscribe(); ``` From 3de62282a7a24ca978f0d6d72431e0bc9d8ff716 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:56:11 +0300 Subject: [PATCH 14/15] Update docs/txn-advanced-features.md [ci skip] --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index a5b06ce802b8..ce29e86521c1 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -46,7 +46,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso For different scenarios, they use different subscriptions and choose different isolation levels. One scenario might require transactions, while another might not. In general, not all subscriptions of the same topic require transaction guarantees. Some want low latency without the exact-once semantic guarantee (like a real-time monitoring system), and some must require the exactly-once guarantee (e.g., business processing systems). Users can freely choose different isolation levels according to different scenarios. -Note that this is a subscription dimension configuration, and all consumers under the same subscription need to be configured with the same IsolationLevel. +Note that this is a subscription-level configuration, and all consumers under the same subscription must be configured with the same `IsolationLevel`. In this example, the consumer builder uses the `READ_UNCOMMITTED` isolation level. From 2b4c7477beb487490fb54ff289d07e1e58dd8256 Mon Sep 17 00:00:00 2001 From: Kiryl Valkovich Date: Thu, 29 Feb 2024 21:57:17 +0300 Subject: [PATCH 15/15] Update docs/txn-advanced-features.md --- docs/txn-advanced-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/txn-advanced-features.md b/docs/txn-advanced-features.md index ce29e86521c1..f00aa6f858c7 100644 --- a/docs/txn-advanced-features.md +++ b/docs/txn-advanced-features.md @@ -46,7 +46,7 @@ To enhance the flexibility of Pulsar transactions, they support two distinct iso For different scenarios, they use different subscriptions and choose different isolation levels. One scenario might require transactions, while another might not. In general, not all subscriptions of the same topic require transaction guarantees. Some want low latency without the exact-once semantic guarantee (like a real-time monitoring system), and some must require the exactly-once guarantee (e.g., business processing systems). Users can freely choose different isolation levels according to different scenarios. -Note that this is a subscription-level configuration, and all consumers under the same subscription must be configured with the same `IsolationLevel`. +Note that this is a subscription-level configuration, and all consumers under the same subscription must be configured with the same isolation level. In this example, the consumer builder uses the `READ_UNCOMMITTED` isolation level.