codelipenghui commented on a change in pull request #8347:
URL: https://github.com/apache/pulsar/pull/8347#discussion_r513857820
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Dispatcher.java
##########
@@ -115,4 +115,9 @@ default void cursorIsReset() {
default void acknowledgementWasProcessed() {
// No-op
}
+
+ default void addMessageToRedelivery(long ledgerId, long entryId) {
Review comment:
```suggestion
default void addMessageToReplay(long ledgerId, long entryId) {
```
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
##########
@@ -447,8 +460,21 @@ protected void readMoreEntries(Consumer consumer) {
}
havePendingRead = true;
- if (transactionReader.havePendingTxnToRead()) {
- transactionReader.read(messagesToRead, consumer, this);
+ if (havePendingReplayRead) {
+ if (log.isDebugEnabled()) {
+ log.debug("have pending replay read");
Review comment:
It's better to print the topic name ,subscription name in the log. You
can refer to other log patterns in the
PersistentDispatcherSingleActiveConsumer.java
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentDispatcherSingleActiveConsumer.java
##########
@@ -73,9 +77,11 @@
private final ServiceConfiguration serviceConfig;
private volatile ScheduledFuture<?> readOnActiveConsumerTask = null;
+ LongPairSet messagesToRedeliver = new ConcurrentSortedLongPairSet(128, 2);
Review comment:
Only instantiate when the transaction is enabled.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractBaseDispatcher.java
##########
@@ -70,11 +69,13 @@ protected AbstractBaseDispatcher(Subscription subscription)
{
*/
public void filterEntriesForConsumer(List<Entry> entries, EntryBatchSizes
batchSizes,
SendMessageInfo sendMessageInfo,
EntryBatchIndexesAcks indexesAcks,
- ManagedCursor cursor,
TransactionReader transactionReader) {
+ ManagedCursor cursor,
TransactionMessageReader transactionMessageReader) {
int totalMessages = 0;
long totalBytes = 0;
int totalChunkedMessages = 0;
+ boolean afterTxnCommitMarker = false;
Review comment:
```suggestion
boolean isAfterTxnCommitMarker = false;
```
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Dispatcher.java
##########
@@ -115,4 +115,9 @@ default void cursorIsReset() {
default void acknowledgementWasProcessed() {
// No-op
}
+
+ default void addMessageToRedelivery(long ledgerId, long entryId) {
Review comment:
I think use replay is more reasonable here. The redeliver looks like
the consumer receiver the messages.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/TransactionMessageDeduplication.java
##########
@@ -0,0 +1,30 @@
+/**
+ * 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;
+
+import org.apache.bookkeeper.mledger.ManagedLedger;
+import org.apache.pulsar.broker.PulsarService;
+
+public class TransactionMessageDeduplication extends MessageDeduplication {
Review comment:
Looks not related to this PR.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/TransactionMessageReader.java
##########
@@ -0,0 +1,110 @@
+/**
+ * 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;
+
+import io.netty.buffer.ByteBuf;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.Executor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.bookkeeper.mledger.Entry;
+import org.apache.bookkeeper.mledger.Position;
+import org.apache.bookkeeper.mledger.impl.PositionImpl;
+import org.apache.pulsar.broker.service.Dispatcher;
+import org.apache.pulsar.broker.service.Subscription;
+import org.apache.pulsar.common.api.proto.PulsarApi;
+import org.apache.pulsar.common.api.proto.PulsarMarkers;
+import org.apache.pulsar.common.protocol.Commands;
+import org.apache.pulsar.common.protocol.Markers;
+import org.apache.pulsar.common.util.collections.ConcurrentLongPairSet;
+
+/**
+ * Transaction message reader.
+ */
+@Slf4j
+public class TransactionMessageReader {
+
+ private final Subscription subscription;
+ private final Dispatcher dispatcher;
+ private final Executor executor;
+
+ private final ConcurrentLongPairSet pendingReadPosition;
Review comment:
We already have `messageToRedeliver` in the Dispatcher, why need to add
a `pendingReadPosition`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]