You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "heesung-sn (via GitHub)" <gi...@apache.org> on 2023/12/04 20:05:24 UTC

[PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting… [pulsar]

heesung-sn opened a new pull request, #21668:
URL: https://github.com/apache/pulsar/pull/21668

   … time configs. Handle AddEntry failure during topic transfer
   
   <!--
   ### Contribution Checklist
     
     - PR title format should be *[type][component] summary*. For details, see *[Guideline - Pulsar PR Naming Convention](https://pulsar.apache.org/contribute/develop-semantic-title/)*. 
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   -->
   
   <!-- Either this PR fixes an issue, -->
   
   Fixes #xyz
   
   <!-- or this PR is one task of an issue -->
   
   Main Issue: #xyz
   
   <!-- If the PR belongs to a PIP, please add the PIP link here -->
   
   PIP: #xyz 
   
   <!-- Details of when a PIP is required and how the PIP process work, please see: https://github.com/apache/pulsar/blob/master/pip/README.md -->
   
   ### Motivation
   
   <!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
   
   ### Modifications
   
   <!-- Describe the modifications you've done. -->
   
   ### Verifying this change
   
   - [ ] Make sure that the change passes the CI checks.
   
   *(Please pick either of the following options)*
   
   This change is a trivial rework / code cleanup without any test coverage.
   
   *(or)*
   
   This change is already covered by existing tests, such as *(please describe tests)*.
   
   *(or)*
   
   This change added tests and can be verified as follows:
   
   *(example:)*
     - *Added integration tests for end-to-end deployment with large payloads (10MB)*
     - *Extended integration test for recovery after broker failure*
   
   ### 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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414747224


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -651,6 +651,19 @@ public void addComplete(Position pos, ByteBuf entryData, Object ctx) {
 
     @Override
     public synchronized void addFailed(ManagedLedgerException exception, Object ctx) {
+        /* If the topic is being transferred(in the Releasing bundle state),
+         we don't want to forcefully close topic here.
+         Instead, we will rely on the service unit state channel's bundle(topic) transfer protocol.
+         At the end of the transfer protocol, at Owned state, the source broker should close the topic properly.
+         */
+        if (transferring) {

Review Comment:
   yes, this is required. Otherwise,`testTransferClientReconnectionWithoutLookup` will be flaky.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java:
##########
@@ -157,6 +157,7 @@ public abstract class AbstractTopic implements Topic, TopicPolicyListener<TopicP
     protected final LongAdder msgOutFromRemovedSubscriptions = new LongAdder();
     protected final LongAdder bytesOutFromRemovedSubscriptions = new LongAdder();
     protected volatile Pair<String, List<EntryFilter>> entryFilters;
+    protected volatile boolean transferring = false;

Review Comment:
   No. I think we should have a different state here. `isFenced=true` can happen in other cases(e.g. when bk write fails), so we need to define a new state separately.



##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java:
##########
@@ -2661,6 +2661,27 @@ The delayed message index time step(in seconds) in per bucket snapshot segment,
     )
     private boolean loadBalancerSheddingBundlesWithPoliciesEnabled = false;
 
+    @FieldContext(
+            category = CATEGORY_LOAD_BALANCER,
+            doc = "Time to wait before fixing any stuck in-flight service unit states. "
+                    + "The leader monitor fixes any in-flight service unit(bundle) states "
+                    + "by reassigning the ownerships if stuck too long, longer than this period."
+                    + "(only used in load balancer extension logics)"
+    )
+    private long loadBalancerInFlightServiceUnitStateWaitingTimeInMillis = 30 * 1000;

Review Comment:
   I don't think we need a PIP for this config, as this is a minor addition (and these need to be tuned rarely). If required, I think we could update the config list in the PIP-192.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose inflight state waiting time and service channel monitor interval configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui merged PR #21668:
URL: https://github.com/apache/pulsar/pull/21668


-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414778635


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java:
##########
@@ -338,7 +338,7 @@ default boolean isSystemTopic() {
 
     boolean isPersistent();
 
-    boolean isFenced();

Review Comment:
   This only introduced for pip-307. Since we dont use it any more, we are deleting 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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414708962


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1473,6 +1486,9 @@ public CompletableFuture<Void> close(
 
         lock.writeLock().lock();
         try {
+            if (!disconnectClients) {
+                transferring = true;

Review Comment:
   Yes, `transferring` will not go back to false. 
   
   In the worst case, if transferring is stuck, the leader monitor will send a msg to the source broker to fix the stuck state with `handleOwnEvent` at the `} else if ((data.force() || isTransferCommand(data)) && isTargetBroker(data.sourceBroker())) {`. In this case, the topics will be forcefully closed with `disconnectClients=true`.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414736153


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -651,6 +651,19 @@ public void addComplete(Position pos, ByteBuf entryData, Object ctx) {
 
     @Override
     public synchronized void addFailed(ManagedLedgerException exception, Object ctx) {
+        /* If the topic is being transferred(in the Releasing bundle state),
+         we don't want to forcefully close topic here.
+         Instead, we will rely on the service unit state channel's bundle(topic) transfer protocol.
+         At the end of the transfer protocol, at Owned state, the source broker should close the topic properly.
+         */
+        if (transferring) {

Review Comment:
   Does this change relevant to the flaky test? If not, a separate PR might be better.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java:
##########
@@ -157,6 +157,7 @@ public abstract class AbstractTopic implements Topic, TopicPolicyListener<TopicP
     protected final LongAdder msgOutFromRemovedSubscriptions = new LongAdder();
     protected final LongAdder bytesOutFromRemovedSubscriptions = new LongAdder();
     protected volatile Pair<String, List<EntryFilter>> entryFilters;
+    protected volatile boolean transferring = false;

Review Comment:
   Can we reuse `isFenced`?



##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java:
##########
@@ -2661,6 +2661,27 @@ The delayed message index time step(in seconds) in per bucket snapshot segment,
     )
     private boolean loadBalancerSheddingBundlesWithPoliciesEnabled = false;
 
+    @FieldContext(
+            category = CATEGORY_LOAD_BALANCER,
+            doc = "Time to wait before fixing any stuck in-flight service unit states. "
+                    + "The leader monitor fixes any in-flight service unit(bundle) states "
+                    + "by reassigning the ownerships if stuck too long, longer than this period."
+                    + "(only used in load balancer extension logics)"
+    )
+    private long loadBalancerInFlightServiceUnitStateWaitingTimeInMillis = 30 * 1000;

Review Comment:
   Do we need a PIP to add configuration? /cc @codelipenghui 



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "dragosvictor (via GitHub)" <gi...@apache.org>.
dragosvictor commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414692856


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1473,6 +1486,9 @@ public CompletableFuture<Void> close(
 
         lock.writeLock().lock();
         try {
+            if (!disconnectClients) {
+                transferring = true;

Review Comment:
   Just confirming that this flag is not meant to ever go back to `false`. Is that the intent? As it is right now, publishing a message to a topic that was transferred would lead to a `TopicClosedException`, whereas in the current proposal the exception would be silenced forever.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java:
##########
@@ -485,6 +485,14 @@ public long getOriginalHighestSequenceId() {
         @Override
         public void completed(Exception exception, long ledgerId, long entryId) {
             if (exception != null) {
+                // if the topic is transferring, we don't send error code to the clients.
+                if (producer.getTopic().isTransferring()) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("[{}] Received producer exception: {} while transferring.",
+                                producer.getTopic().getName(), exception.getMessage(), exception);
+                    }
+                    return;
+                }

Review Comment:
   Would we still need to execute the code inside the lambda below, except the error sending? There's other cleanup operations being performed that can avoid resource leaks.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "dragosvictor (via GitHub)" <gi...@apache.org>.
dragosvictor commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414453875


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -200,33 +197,25 @@ enum MetadataState {
         Unstable
     }
 
-    public static ServiceUnitStateChannelImpl newInstance(PulsarService pulsar) {
-        return new ServiceUnitStateChannelImpl(pulsar);
-    }
-
-    public ServiceUnitStateChannelImpl(PulsarService pulsar) {
-        this(pulsar, MAX_IN_FLIGHT_STATE_WAITING_TIME_IN_MILLIS, OWNERSHIP_MONITOR_DELAY_TIME_IN_SECS);
-    }
-
     @VisibleForTesting
-    public ServiceUnitStateChannelImpl(PulsarService pulsar,
-                                       long inFlightStateWaitingTimeInMillis,
-                                       long ownershipMonitorDelayTimeInSecs) {
+    public ServiceUnitStateChannelImpl(PulsarService pulsar) {
         this.pulsar = pulsar;
         this.config = pulsar.getConfig();
         this.lookupServiceAddress = pulsar.getLookupServiceAddress();
         this.schema = Schema.JSON(ServiceUnitStateData.class);
         this.getOwnerRequests = new ConcurrentHashMap<>();
         this.cleanupJobs = new ConcurrentHashMap<>();
         this.stateChangeListeners = new StateChangeListeners();
-        this.semiTerminalStateWaitingTimeInMillis = config.getLoadBalancerServiceUnitStateTombstoneDelayTimeInSeconds()
+        this.stateTombstoneDelayTimeInSeconds = config.getLoadBalancerServiceUnitStateTombstoneDelayTimeInSeconds()
                 * 1000;

Review Comment:
   Nit: this shouldn't be multiplied by 1000 anymore.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java:
##########
@@ -468,8 +459,11 @@ public void testTransferClientReconnectionWithoutLookup(boolean isPersistentTopi
                 throw new RuntimeException(e);
             }
         });
-        assertTrue(producer.isConnected());
-        verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+
+        Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+            assertTrue(producer.isConnected());
+            verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+        });

Review Comment:
   Can we simplify as suggested below? We aren't expecting any new calls to `lookup.getBroker(topicName)`, we could go further and replace the condition with `never()`.
   
   ```suggestion
           Awaitility.await().atMost(5, TimeUnit.SECONDS).until(producer::isConnected);
           verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
   ```



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -652,6 +652,20 @@ public void addComplete(Position pos, ByteBuf entryData, Object ctx) {
     @Override
     public synchronized void addFailed(ManagedLedgerException exception, Object ctx) {
         PublishContext callback = (PublishContext) ctx;
+
+        /* If the topic is being transferred(in the Releasing bundle state),
+         we don't want to forcefully close topic here.
+         Instead, we will rely on the service unit state channel's bundle(topic) transfer protocol.
+         At the end of the transfer protocol, at Owned state, the source broker should close the topic properly.
+         */
+        if (isClosingOrDeleting
+                && ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(getBrokerService().pulsar())) {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] Failed to persist msg in store: {} while closing or deleting.",
+                        topic, exception.getMessage(), exception);
+            }
+            return;
+        }

Review Comment:
   Looks correct, but is there anything to be done about the `PublishContext` callback?



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -200,33 +197,25 @@ enum MetadataState {
         Unstable
     }
 
-    public static ServiceUnitStateChannelImpl newInstance(PulsarService pulsar) {
-        return new ServiceUnitStateChannelImpl(pulsar);
-    }
-
-    public ServiceUnitStateChannelImpl(PulsarService pulsar) {
-        this(pulsar, MAX_IN_FLIGHT_STATE_WAITING_TIME_IN_MILLIS, OWNERSHIP_MONITOR_DELAY_TIME_IN_SECS);
-    }
-
     @VisibleForTesting
-    public ServiceUnitStateChannelImpl(PulsarService pulsar,
-                                       long inFlightStateWaitingTimeInMillis,
-                                       long ownershipMonitorDelayTimeInSecs) {
+    public ServiceUnitStateChannelImpl(PulsarService pulsar) {
         this.pulsar = pulsar;
         this.config = pulsar.getConfig();
         this.lookupServiceAddress = pulsar.getLookupServiceAddress();
         this.schema = Schema.JSON(ServiceUnitStateData.class);
         this.getOwnerRequests = new ConcurrentHashMap<>();
         this.cleanupJobs = new ConcurrentHashMap<>();
         this.stateChangeListeners = new StateChangeListeners();
-        this.semiTerminalStateWaitingTimeInMillis = config.getLoadBalancerServiceUnitStateTombstoneDelayTimeInSeconds()
+        this.stateTombstoneDelayTimeInSeconds = config.getLoadBalancerServiceUnitStateTombstoneDelayTimeInSeconds()
                 * 1000;
-        this.inFlightStateWaitingTimeInMillis = inFlightStateWaitingTimeInMillis;
-        this.ownershipMonitorDelayTimeInSecs = ownershipMonitorDelayTimeInSecs;
-        if (semiTerminalStateWaitingTimeInMillis < inFlightStateWaitingTimeInMillis) {
+        this.inFlightStateWaitingTimeInMillis = config.getLoadBalancerInFlightServiceUnitStateWaitingTimeInMillis();
+        this.ownershipMonitorDelayTimeInSecs = config.getLoadBalancerServiceUnitStateMonitorIntervalInSeconds();
+        if (stateTombstoneDelayTimeInSeconds < inFlightStateWaitingTimeInMillis) {
             throw new IllegalArgumentException(

Review Comment:
   Nit: comparing seconds to milliseconds.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -1457,7 +1446,7 @@ protected void monitorOwnerships(List<String> brokers) {
                 continue;
             }
 
-            if (now - stateData.timestamp() > semiTerminalStateWaitingTimeInMillis) {
+            if (now - stateData.timestamp() > stateTombstoneDelayTimeInSeconds) {

Review Comment:
   Nit: comparing seconds to milliseconds.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -654,12 +654,12 @@ public void splitAndRetryTest() throws Exception {
         FieldUtils.writeDeclaredField(channel1,
                 "inFlightStateWaitingTimeInMillis", 30 * 1000, true);
         FieldUtils.writeDeclaredField(channel1,
-                "semiTerminalStateWaitingTimeInMillis", 300 * 1000, true);
+                "stateTombstoneDelayTimeInSeconds", 300 * 1000, true);

Review Comment:
   Here and below: are these values still correct, since we switched to a different time unit?



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414779331


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java:
##########
@@ -338,7 +338,7 @@ default boolean isSystemTopic() {
 
     boolean isPersistent();
 
-    boolean isFenced();

Review Comment:
   I see, thanks for explaining.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1416053744


##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java:
##########
@@ -2661,6 +2661,27 @@ The delayed message index time step(in seconds) in per bucket snapshot segment,
     )
     private boolean loadBalancerSheddingBundlesWithPoliciesEnabled = false;
 
+    @FieldContext(
+            category = CATEGORY_LOAD_BALANCER,
+            doc = "Time to wait before fixing any stuck in-flight service unit states. "
+                    + "The leader monitor fixes any in-flight service unit(bundle) states "
+                    + "by reassigning the ownerships if stuck too long, longer than this period."
+                    + "(only used in load balancer extension logics)"
+    )
+    private long loadBalancerInFlightServiceUnitStateWaitingTimeInMillis = 30 * 1000;

Review Comment:
   I updated the PIP-192 to list the ExtensibleLoadBalancer's Service Configurations.
   I shared this info in the mailing list. https://lists.apache.org/thread/zz612q2bhh6rccl04w3jz2mvt0z5kch8



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn closed pull request #21668: [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer
URL: https://github.com/apache/pulsar/pull/21668


-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "dragosvictor (via GitHub)" <gi...@apache.org>.
dragosvictor commented on PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#issuecomment-1839862802

   Looks good to me, thanks!


-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414511600


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java:
##########
@@ -468,8 +459,11 @@ public void testTransferClientReconnectionWithoutLookup(boolean isPersistentTopi
                 throw new RuntimeException(e);
             }
         });
-        assertTrue(producer.isConnected());
-        verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+
+        Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+            assertTrue(producer.isConnected());
+            verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+        });

Review Comment:
   Updated.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelTest.java:
##########
@@ -654,12 +654,12 @@ public void splitAndRetryTest() throws Exception {
         FieldUtils.writeDeclaredField(channel1,
                 "inFlightStateWaitingTimeInMillis", 30 * 1000, true);
         FieldUtils.writeDeclaredField(channel1,
-                "semiTerminalStateWaitingTimeInMillis", 300 * 1000, true);
+                "stateTombstoneDelayTimeInSeconds", 300 * 1000, true);

Review Comment:
   fixed.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414505512


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -652,6 +652,20 @@ public void addComplete(Position pos, ByteBuf entryData, Object ctx) {
     @Override
     public synchronized void addFailed(ManagedLedgerException exception, Object ctx) {
         PublishContext callback = (PublishContext) ctx;
+
+        /* If the topic is being transferred(in the Releasing bundle state),
+         we don't want to forcefully close topic here.
+         Instead, we will rely on the service unit state channel's bundle(topic) transfer protocol.
+         At the end of the transfer protocol, at Owned state, the source broker should close the topic properly.
+         */
+        if (isClosingOrDeleting
+                && ExtensibleLoadManagerImpl.isLoadManagerExtensionEnabled(getBrokerService().pulsar())) {
+            if (log.isDebugEnabled()) {
+                log.debug("[{}] Failed to persist msg in store: {} while closing or deleting.",
+                        topic, exception.getMessage(), exception);
+            }
+            return;
+        }

Review Comment:
   I think the callback is used to signal clients to additionally handle this case on the clients as well. In this case, we don't need to send any to the clients.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting… [pulsar]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#issuecomment-1839391027

   @heesung-sn Please add the following content to your PR description and select a checkbox:
   ```
   - [ ] `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 -->
   ```


-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "dragosvictor (via GitHub)" <gi...@apache.org>.
dragosvictor commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414734275


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1473,6 +1486,9 @@ public CompletableFuture<Void> close(
 
         lock.writeLock().lock();
         try {
+            if (!disconnectClients) {
+                transferring = true;

Review Comment:
   I agree, the topics will be forcefully closed as you mentioned, but further messages produced will still be ignored instead of responded to with `TopicClosedException`.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "Demogorgon314 (via GitHub)" <gi...@apache.org>.
Demogorgon314 commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414763705


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java:
##########
@@ -338,7 +338,7 @@ default boolean isSystemTopic() {
 
     boolean isPersistent();
 
-    boolean isFenced();

Review Comment:
   Should we keep this interface here? It might break some protocol handler compatibility if removed



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414778635


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java:
##########
@@ -338,7 +338,7 @@ default boolean isSystemTopic() {
 
     boolean isPersistent();
 
-    boolean isFenced();

Review Comment:
   No. This only introduced for pip-307. Since we dont use it any more, we are deleting 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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414511600


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java:
##########
@@ -468,8 +459,11 @@ public void testTransferClientReconnectionWithoutLookup(boolean isPersistentTopi
                 throw new RuntimeException(e);
             }
         });
-        assertTrue(producer.isConnected());
-        verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+
+        Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+            assertTrue(producer.isConnected());
+            verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+        });

Review Comment:
   Updated.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414653715


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/loadbalance/extensions/ExtensibleLoadManagerImplTest.java:
##########
@@ -468,8 +459,11 @@ public void testTransferClientReconnectionWithoutLookup(boolean isPersistentTopi
                 throw new RuntimeException(e);
             }
         });
-        assertTrue(producer.isConnected());
-        verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+
+        Awaitility.await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> {
+            assertTrue(producer.isConnected());
+            verify(lookup, times(lookupCountBeforeUnload)).getBroker(topicName);
+        });

Review Comment:
   Updated.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414723107


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Producer.java:
##########
@@ -485,6 +485,14 @@ public long getOriginalHighestSequenceId() {
         @Override
         public void completed(Exception exception, long ledgerId, long entryId) {
             if (exception != null) {
+                // if the topic is transferring, we don't send error code to the clients.
+                if (producer.getTopic().isTransferring()) {
+                    if (log.isDebugEnabled()) {
+                        log.debug("[{}] Received producer exception: {} while transferring.",
+                                producer.getTopic().getName(), exception.getMessage(), exception);
+                    }
+                    return;
+                }

Review Comment:
   I agree. Moving this logic into the lambda and continue to call the cleanups. Thank you.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java:
##########
@@ -1473,6 +1486,9 @@ public CompletableFuture<Void> close(
 
         lock.writeLock().lock();
         try {
+            if (!disconnectClients) {
+                transferring = true;

Review Comment:
   Yes, `transferring` will not go back to false. 
   
   In the worst case, if transferring is stuck, the leader monitor will fix the stuck state with `handleOwnEvent` at the `} else if ((data.force() || isTransferCommand(data)) && isTargetBroker(data.sourceBroker())) {`. In this case, the topics will be forcefully closed with `disconnectClients=true`.



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "heesung-sn (via GitHub)" <gi...@apache.org>.
heesung-sn commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414494799


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/loadbalance/extensions/channel/ServiceUnitStateChannelImpl.java:
##########
@@ -200,33 +197,25 @@ enum MetadataState {
         Unstable
     }
 
-    public static ServiceUnitStateChannelImpl newInstance(PulsarService pulsar) {
-        return new ServiceUnitStateChannelImpl(pulsar);
-    }
-
-    public ServiceUnitStateChannelImpl(PulsarService pulsar) {
-        this(pulsar, MAX_IN_FLIGHT_STATE_WAITING_TIME_IN_MILLIS, OWNERSHIP_MONITOR_DELAY_TIME_IN_SECS);
-    }
-
     @VisibleForTesting
-    public ServiceUnitStateChannelImpl(PulsarService pulsar,
-                                       long inFlightStateWaitingTimeInMillis,
-                                       long ownershipMonitorDelayTimeInSecs) {
+    public ServiceUnitStateChannelImpl(PulsarService pulsar) {
         this.pulsar = pulsar;
         this.config = pulsar.getConfig();
         this.lookupServiceAddress = pulsar.getLookupServiceAddress();
         this.schema = Schema.JSON(ServiceUnitStateData.class);
         this.getOwnerRequests = new ConcurrentHashMap<>();
         this.cleanupJobs = new ConcurrentHashMap<>();
         this.stateChangeListeners = new StateChangeListeners();
-        this.semiTerminalStateWaitingTimeInMillis = config.getLoadBalancerServiceUnitStateTombstoneDelayTimeInSeconds()
+        this.stateTombstoneDelayTimeInSeconds = config.getLoadBalancerServiceUnitStateTombstoneDelayTimeInSeconds()
                 * 1000;

Review Comment:
   oh thanks for this catch. The name should `stateTombstoneDelayTimeInMillis`



-- 
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


Re: [PR] [improve][broker] PIP-307 Expose tombstone and inflight state waiting time configs. Handle AddEntry failure during topic transfer [pulsar]

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on code in PR #21668:
URL: https://github.com/apache/pulsar/pull/21668#discussion_r1414931181


##########
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java:
##########
@@ -2661,6 +2661,27 @@ The delayed message index time step(in seconds) in per bucket snapshot segment,
     )
     private boolean loadBalancerSheddingBundlesWithPoliciesEnabled = false;
 
+    @FieldContext(
+            category = CATEGORY_LOAD_BALANCER,
+            doc = "Time to wait before fixing any stuck in-flight service unit states. "
+                    + "The leader monitor fixes any in-flight service unit(bundle) states "
+                    + "by reassigning the ownerships if stuck too long, longer than this period."
+                    + "(only used in load balancer extension logics)"
+    )
+    private long loadBalancerInFlightServiceUnitStateWaitingTimeInMillis = 30 * 1000;

Review Comment:
   Yes, update PIP-192 makes sense. It’s better to share in the mailing list.



-- 
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