You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lifepuzzlefun (via GitHub)" <gi...@apache.org> on 2023/06/17 05:17:22 UTC
[GitHub] [pulsar] lifepuzzlefun opened a new pull request, #20597: [fix][broker] Fix NPE when reset Replicator's cursor by position.
lifepuzzlefun opened a new pull request, #20597:
URL: https://github.com/apache/pulsar/pull/20597
### Motivation
There is an PersistentMessageExpiryMonitor in AbstractReplicator.
but when init in AbstractReplicator. the field of `PersistentMessageExpiryMonitor` is null.
so an EPE throws when no null check.
### Modifications
save PersistentTopic in `PersistentMessageExpiryMonitor` field.
ensure when call `expireMessages(Position messagePosition)` only check topic LastPosition by topic. not null subscription.
### Verifying this change
add new test to verify the method wont throw npe. but not the logic.
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*If the box was checked, please highlight the changes*
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: <!-- ENTER URL HERE -->
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
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
[GitHub] [pulsar] lifepuzzlefun commented on a diff in pull request #20597: [fix][broker] Fix NPE when reset Replicator's cursor by position.
Posted by "lifepuzzlefun (via GitHub)" <gi...@apache.org>.
lifepuzzlefun commented on code in PR #20597:
URL: https://github.com/apache/pulsar/pull/20597#discussion_r1245252741
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java:
##########
@@ -728,6 +728,40 @@ public void testReplicatorClearBacklog() throws Exception {
assertEquals(status.getReplicationBacklog(), 0);
}
+
+ @Test(timeOut = 30000)
+ public void testResetReplicatorSubscriptionPosition() throws Exception {
+ final TopicName dest = TopicName
+ .get(BrokerTestUtil.newUniqueName("persistent://pulsar/ns/resetReplicatorSubscription"));
+
+ @Cleanup
+ MessageProducer producer1 = new MessageProducer(url1, dest);
+
+ @Cleanup
+ MessageConsumer consumer1 = new MessageConsumer(url3, dest);
+
+ // Produce from cluster1 and consume from the rest
+ for (int i = 0; i < 10; i++) {
+ producer1.produce(2);
+ }
+
+ PersistentTopic topic = (PersistentTopic) pulsar1.getBrokerService().getTopicReference(dest.toString()).get();
+
+ Position lastPosition = topic.getLastPosition();
+
+ PersistentReplicator replicator = (PersistentReplicator) spy(
+ topic.getReplicators().get(topic.getReplicators().keys().get(0)));
+
+ // make replicator backoff readMessage.
+ replicator.readEntriesFailed(new ManagedLedgerException.InvalidCursorPositionException("failed"), null);
+
+ replicator.updateRates(); // for code-coverage
+
+ replicator.expireMessages(lastPosition); // for code-coverage
Review Comment:
Nice suggestion. and it looks like we found another problem. the admin api not support expire replicator also. I have change the logic. please check `PersistentTopicsBase.internalExpireMessagesNonPartitionedTopicByPosition` again.
--
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
[GitHub] [pulsar] poorbarcode commented on a diff in pull request #20597: [fix][broker] Fix NPE when reset Replicator's cursor by position.
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20597:
URL: https://github.com/apache/pulsar/pull/20597#discussion_r1244811010
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java:
##########
@@ -728,6 +728,40 @@ public void testReplicatorClearBacklog() throws Exception {
assertEquals(status.getReplicationBacklog(), 0);
}
+
+ @Test(timeOut = 30000)
+ public void testResetReplicatorSubscriptionPosition() throws Exception {
+ final TopicName dest = TopicName
+ .get(BrokerTestUtil.newUniqueName("persistent://pulsar/ns/resetReplicatorSubscription"));
+
+ @Cleanup
+ MessageProducer producer1 = new MessageProducer(url1, dest);
+
+ @Cleanup
+ MessageConsumer consumer1 = new MessageConsumer(url3, dest);
Review Comment:
We can remove the unnecessary consumer
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java:
##########
@@ -728,6 +728,40 @@ public void testReplicatorClearBacklog() throws Exception {
assertEquals(status.getReplicationBacklog(), 0);
}
+
+ @Test(timeOut = 30000)
+ public void testResetReplicatorSubscriptionPosition() throws Exception {
+ final TopicName dest = TopicName
+ .get(BrokerTestUtil.newUniqueName("persistent://pulsar/ns/resetReplicatorSubscription"));
+
+ @Cleanup
+ MessageProducer producer1 = new MessageProducer(url1, dest);
+
+ @Cleanup
+ MessageConsumer consumer1 = new MessageConsumer(url3, dest);
+
+ // Produce from cluster1 and consume from the rest
+ for (int i = 0; i < 10; i++) {
+ producer1.produce(2);
+ }
+
+ PersistentTopic topic = (PersistentTopic) pulsar1.getBrokerService().getTopicReference(dest.toString()).get();
+
+ Position lastPosition = topic.getLastPosition();
+
+ PersistentReplicator replicator = (PersistentReplicator) spy(
+ topic.getReplicators().get(topic.getReplicators().keys().get(0)));
+
+ // make replicator backoff readMessage.
+ replicator.readEntriesFailed(new ManagedLedgerException.InvalidCursorPositionException("failed"), null);
+
+ replicator.updateRates(); // for code-coverage
+
+ replicator.expireMessages(lastPosition); // for code-coverage
Review Comment:
Could you add a new test use admin API to reproduce this issue?
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ReplicatorTest.java:
##########
@@ -728,6 +728,40 @@ public void testReplicatorClearBacklog() throws Exception {
assertEquals(status.getReplicationBacklog(), 0);
}
+
+ @Test(timeOut = 30000)
+ public void testResetReplicatorSubscriptionPosition() throws Exception {
+ final TopicName dest = TopicName
+ .get(BrokerTestUtil.newUniqueName("persistent://pulsar/ns/resetReplicatorSubscription"));
+
+ @Cleanup
+ MessageProducer producer1 = new MessageProducer(url1, dest);
+
+ @Cleanup
+ MessageConsumer consumer1 = new MessageConsumer(url3, dest);
+
+ // Produce from cluster1 and consume from the rest
+ for (int i = 0; i < 10; i++) {
+ producer1.produce(2);
+ }
+
+ PersistentTopic topic = (PersistentTopic) pulsar1.getBrokerService().getTopicReference(dest.toString()).get();
+
+ Position lastPosition = topic.getLastPosition();
+
+ PersistentReplicator replicator = (PersistentReplicator) spy(
+ topic.getReplicators().get(topic.getReplicators().keys().get(0)));
+
+ // make replicator backoff readMessage.
+ replicator.readEntriesFailed(new ManagedLedgerException.InvalidCursorPositionException("failed"), null);
Review Comment:
I think this step is unnecessary, can we remove it?
--
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
[GitHub] [pulsar] codecov-commenter commented on pull request #20597: [fix][broker] Fix NPE when reset Replicator's cursor by position.
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #20597:
URL: https://github.com/apache/pulsar/pull/20597#issuecomment-1614134186
## [Codecov](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
> Merging [#20597](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (8c9b1d3) into [master](https://app.codecov.io/gh/apache/pulsar/commit/0e603405c2a6faaa50a47881916a2c1268de9830?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) (0e60340) will **increase** coverage by `0.51%`.
> The diff coverage is `73.07%`.
[](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #20597 +/- ##
============================================
+ Coverage 72.60% 73.11% +0.51%
+ Complexity 32018 31936 -82
============================================
Files 1855 1867 +12
Lines 138569 138764 +195
Branches 15250 15265 +15
============================================
+ Hits 100605 101458 +853
+ Misses 29945 29258 -687
- Partials 8019 8048 +29
```
| Flag | Coverage Δ | |
|---|---|---|
| inttests | `24.05% <19.23%> (-0.06%)` | :arrow_down: |
| systests | `25.04% <15.38%> (?)` | |
| unittests | `72.39% <73.07%> (+0.03%)` | :arrow_up: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [...pulsar/broker/admin/impl/PersistentTopicsBase.java](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL1BlcnNpc3RlbnRUb3BpY3NCYXNlLmphdmE=) | `64.30% <63.15%> (+0.17%)` | :arrow_up: |
| [...ice/persistent/PersistentMessageExpiryMonitor.java](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3BlcnNpc3RlbnQvUGVyc2lzdGVudE1lc3NhZ2VFeHBpcnlNb25pdG9yLmphdmE=) | `70.10% <100.00%> (+1.35%)` | :arrow_up: |
| [...roker/service/persistent/PersistentReplicator.java](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3BlcnNpc3RlbnQvUGVyc2lzdGVudFJlcGxpY2F0b3IuamF2YQ==) | `69.46% <100.00%> (+0.67%)` | :arrow_up: |
| [...ker/service/persistent/PersistentSubscription.java](https://app.codecov.io/gh/apache/pulsar/pull/20597?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9zZXJ2aWNlL3BlcnNpc3RlbnQvUGVyc2lzdGVudFN1YnNjcmlwdGlvbi5qYXZh) | `75.91% <100.00%> (ø)` | |
... and [144 files with indirect coverage changes](https://app.codecov.io/gh/apache/pulsar/pull/20597/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
--
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
[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #20597: [fix][broker] Fix NPE when reset Replicator's cursor by position.
Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #20597:
URL: https://github.com/apache/pulsar/pull/20597#discussion_r1252559051
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -57,9 +59,10 @@ public class PersistentMessageExpiryMonitor implements FindEntryCallback {
expirationCheckInProgressUpdater = AtomicIntegerFieldUpdater
.newUpdater(PersistentMessageExpiryMonitor.class, "expirationCheckInProgress");
- public PersistentMessageExpiryMonitor(String topicName, String subscriptionName, ManagedCursor cursor,
- PersistentSubscription subscription) {
- this.topicName = topicName;
+ public PersistentMessageExpiryMonitor(PersistentTopic topic, String subscriptionName, ManagedCursor cursor,
+ @Nullable PersistentSubscription subscription) {
Review Comment:
This PR modifies the public API (even it's in the `pulsar-broker` module), we should not cherry-pick it to release branches unless we make it compatible. @poorbarcode @Technoboy-
--
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
[GitHub] [pulsar] Technoboy- merged pull request #20597: [fix][broker] Fix NPE when reset Replicator's cursor by position.
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- merged PR #20597:
URL: https://github.com/apache/pulsar/pull/20597
--
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