You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/05/10 14:12:25 UTC

[GitHub] [pulsar] liangyepianzhou commented on a diff in pull request #15137: [PIP-153][optimize][txn] Optimize metadataPositions in MLPendingAckStore

liangyepianzhou commented on code in PR #15137:
URL: https://github.com/apache/pulsar/pull/15137#discussion_r869292141


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/pendingack/impl/MLPendingAckStore.java:
##########
@@ -292,6 +250,68 @@ public void addFailed(ManagedLedgerException exception, Object ctx) {
         return completableFuture;
     }
 
+    private void handleMetadataEntry(PositionImpl logPosition, PendingAckMetadataEntry pendingAckMetadataEntry) {
+        // store the persistent position in to memory
+        // store the max position of this entry retain
+        if (pendingAckMetadataEntry.getPendingAckOp() != PendingAckOp.ABORT
+                && pendingAckMetadataEntry.getPendingAckOp() != PendingAckOp.COMMIT) {
+            Optional<PendingAckMetadata> optional = pendingAckMetadataEntry.getPendingAckMetadatasList()
+                    .stream().max((o1, o2) -> ComparisonChain.start().compare(o1.getLedgerId(),
+                            o2.getLedgerId()).compare(o1.getEntryId(), o2.getEntryId()).result());
+
+            optional.ifPresent(pendingAckMetadata -> {
+                PositionImpl nowPosition = PositionImpl.get(pendingAckMetadata.getLedgerId(),
+                        pendingAckMetadata.getEntryId());
+
+                if (nowPosition.compareTo(maxAckPosition) > 0) {
+                    maxAckPosition = nowPosition;
+                }
+                if (currentIndexLag.get() >= maxIndexLag) {
+                    pendingAckLogIndex.compute(maxAckPosition,

Review Comment:
   Yeap, it no longer stores the all position mapping.



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