poorbarcode commented on code in PR #21423:
URL: https://github.com/apache/pulsar/pull/21423#discussion_r1435836234


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/BlockDispatcherSignatureOnCursorDataCanNotFullyPersist.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service.persistent;
+
+/***
+ * A signature that relate to the check of "Dispatching has paused on cursor 
data can fully persist".
+ * Note: do not use this field to confirm whether the delivery should be 
paused,
+ *      please call {@link 
PersistentDispatcherMultipleConsumers#shouldPauseOnAckStatePersist}.
+ */
+public class BlockDispatcherSignatureOnCursorDataCanNotFullyPersist {
+
+    /**
+     * Used to mark that dispatching was paused at least once in the earlier 
time, due to the cursor data can not be
+     * fully persistent.
+     * Why need this filed? It just prevents that
+     * {@link 
PersistentDispatcherMultipleConsumers#afterAckMessages(Throwable, Object)} calls
+     * {@link PersistentDispatcherMultipleConsumers#readMoreEntries()} every 
time, it can avoid too many CPU circles.
+     * We just call {@link 
PersistentDispatcherMultipleConsumers#readMoreEntries()} after the dispatching 
has been
+     * paused at least once earlier.
+     */
+    private volatile boolean markerPausedAtLeastOnce;
+
+    /**
+     * Used to mark some acknowledgements were executed.
+     * Because there is a race condition might cause dispatching stuck, the 
steps to reproduce the issue is like below:
+     * - {@link #markerPausedAtLeastOnce} is "false" now.
+     * - Thread-reading-entries: there are too many ack holes, so start to 
pause dispatching
+     * - Thread-ack: acked all messages.

Review Comment:
   Once this line `afterAckMessages` is executed, it means the acknowledgment 
task has been finished, right? Then the check 
`cursor.isCursorDataFullyPersistable()` of both operation `afterAckMessages` 
and `shouldPauseOnAckStatePersist` will get a same result, right? 



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/BlockDispatcherSignatureOnCursorDataCanNotFullyPersist.java:
##########
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service.persistent;
+
+/***
+ * A signature that relate to the check of "Dispatching has paused on cursor 
data can fully persist".
+ * Note: do not use this field to confirm whether the delivery should be 
paused,
+ *      please call {@link 
PersistentDispatcherMultipleConsumers#shouldPauseOnAckStatePersist}.
+ */
+public class BlockDispatcherSignatureOnCursorDataCanNotFullyPersist {
+
+    /**
+     * Used to mark that dispatching was paused at least once in the earlier 
time, due to the cursor data can not be
+     * fully persistent.
+     * Why need this filed? It just prevents that
+     * {@link 
PersistentDispatcherMultipleConsumers#afterAckMessages(Throwable, Object)} calls
+     * {@link PersistentDispatcherMultipleConsumers#readMoreEntries()} every 
time, it can avoid too many CPU circles.
+     * We just call {@link 
PersistentDispatcherMultipleConsumers#readMoreEntries()} after the dispatching 
has been
+     * paused at least once earlier.
+     */
+    private volatile boolean markerPausedAtLeastOnce;
+
+    /**
+     * Used to mark some acknowledgements were executed.
+     * Because there is a race condition might cause dispatching stuck, the 
steps to reproduce the issue is like below:
+     * - {@link #markerPausedAtLeastOnce} is "false" now.
+     * - Thread-reading-entries: there are too many ack holes, so start to 
pause dispatching
+     * - Thread-ack: acked all messages.

Review Comment:
   Once this line `afterAckMessages` is executed, it means the acknowledgment 
task has been finished, right? Then the check 
`cursor.isCursorDataFullyPersistable()` of both operation `afterAckMessages` 
and `shouldPauseOnAckStatePersist` will get the same result, right? 



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