-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[PIP-63] Readonly-Topic-Ownership-Support #11960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You can apply following diff to fix C++ client build failure. diff --git a/pulsar-client-cpp/lib/Commands.cc b/pulsar-client-cpp/lib/Commands.cc
index 87c149c5b87..760549aaa31 100644
--- a/pulsar-client-cpp/lib/Commands.cc
+++ b/pulsar-client-cpp/lib/Commands.cc
@@ -642,6 +642,18 @@ std::string Commands::messageType(BaseCommand_Type type) {
case BaseCommand::END_TXN_ON_SUBSCRIPTION_RESPONSE:
return "END_TXN_ON_SUBSCRIPTION_RESPONSE";
break;
+ case BaseCommand::GET_CURSOR:
+ return "GET_CURSOR";
+ case BaseCommand::GET_CURSOR_RESPONSE:
+ return "GET_CURSOR_RESPONSE";
+ case BaseCommand::CREATE_CURSOR:
+ return "CREATE_CURSOR";
+ case BaseCommand::CREATE_CURSOR_RESPONSE:
+ return "CREATE_CURSOR_RESPONSE";
+ case BaseCommand::DELETE_CURSOR:
+ return "DELETE_CURSOR";
+ case BaseCommand::UPDATE_CURSOR:
+ return "UPDATE_CURSOR";
};
BOOST_THROW_EXCEPTION(std::logic_error("Invalid BaseCommand enumeration value"));
} |
/pulsarbot run-failure-checks |
Thanks for your patch. :) |
/pulsarbot run-failure-checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This work is very interesting.
I see that many parts are not described in PIP-63 document.
Also, regarding the configuration I would add explicitly a flag that means that a namespace is a "readonly view" over another namespace.
pulsar-client-admin-api/src/main/java/org/apache/pulsar/common/policies/data/Policies.java
Show resolved
Hide resolved
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/CursorClient.java
Show resolved
Hide resolved
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
@Jason918 Thanks for your contribution. For this PR, do we need to update docs? (The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks) |
@Anonymitaet About user doc, This PR is not ready for end users to use this feature in a very convenient way. For example, some parameters is added in namespace policies, but it is not covered in pulsar-admin or REST admin interface. |
@Jason918 thanks for your info! |
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@codelipenghui @linlinnn Hi, can you please take a look at this PR? |
@@ -1850,6 +1831,10 @@ public void operationFailed(ManagedLedgerException exception) { | |||
}); | |||
} | |||
|
|||
protected void persistPosition(MarkDeleteEntry mdEntry, VoidCallback callback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A minor question, why we need this wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RemoteManagedCursorImpl
overrided this method and use CursorClient to persist this 'mdEntry' to topic write owner.
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
This PR is too large, and very hard to review throughly. |
Implementation of PIP-63
User manual
Here is the manual for admin and consumer to use this feature. This part is actually missing in PIP-63.
For example, given a cluster called "my-cluster" with 2 brokers, 192.168.0.1 and 192.168.0.2.
It has namespace called "my-tenant/writer-namespace".And consumers are consuming with service url "pulsar://192.168.0.1:6550,192.168.0.2:6650".
Here is the steps to set up readonly namespace on a new broker 192.168.0.3.
Most importantly, we will not expose the readonly-namespace to consumer users, and no other configuration is needed to achieve this. Once admin sets up the readonly namespace, they can update serviceUrl on their own with some external service governance mechanism. So it's transparent to consumers. Here is image showing the new cluster state.
Motivation
See PIP-63
Modifications
As described in PIP-63. This pr comes with the key changes.
A) Readonly namespace lookup
The following figure show the lookup procedure with some pre-settings.
A new string field
redirectTopic
needs to be added to CommandLookupTopicResponse.In step 1, broker-3 have the info that the
writerNamespace
of "my-tenant/reader-namespace" is "my-tenant/writer-namespace" and broker-3 itself is in the isolation-policy of "my-tenant/reader-namespace". So when it receive lookup request of "my-tenant/writer-namespace", it will redirect the lookup to the leader and change the namespace of the lookup topic to "my-tenant/reader-namespace". So in the following steps(3-6), "persistent://my-tenant/reader-namespace/topic" is used to finish the lookup request.B) How readonly topic owner read data
Related logic is mostly handled in
org.apache.bookkeeper.mledger.impl.RemoteManagedLedgerImpl
which extendsManagedLedgerImpl
for readonly topics, and changed some key behaviors, includingorg.apache.bookkeeper.client.api.ReadHandle#readLastAddConfirmedAsync
of the last ledger in the ledger list. See methodRemoteManagedLedgerImpl#asyncUpdateLastConfirmedEntry()
for details.org.apache.pulsar.client.api.CursorClient
for managing cursors in writer topic. And it's RemoteManagedCursorImpl which extends ManagedCursorImpl used for cursor management in readonly topic.RemoteManagedCursorImpl#checkForNewEntries
will triggerasyncUpdateLastConfirmedEntry
to update LAC from bookies. It's not quite efficient for now, but I look forward to optimize this to a long polling way from broker (or bookie) in the following PRs, since this PR is already quite big for reviewers.C) How does readonly topic owner keep metadata in-sync
Add a method
watchManagedLedgerInfo
inorg.apache.bookkeeper.mledger.impl.MetaStore
.Every
RemoteManagedLedgerImpl
will watch its ManagedLedgerInfo to see if there is a new ledger rolled.D) How does readonly topic owner handle acknowledgment
As described in PIP-63, A set of “cursor” related RPCs between writable topic owner and readonly topic owners is introduced for the acknowledgment. Here is the details.
User docs can be find in "pulsar-client-api/src/main/java/org/apache/pulsar/client/api/CursorClient.java"
A CursorClient is added for readonly topic owners to use these apis. A little different from PIP-63 in Topic Loading and Ack.
Verifying this change
This change added tests and can be verified as follows:
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
Check the box below and label this PR (if you have committer privilege).
doc
(If this PR contains doc changes)