liangyepianzhou commented on code in PR #15137:
URL: https://github.com/apache/pulsar/pull/15137#discussion_r850997628
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/pendingack/impl/MLPendingAckStore.java:
##########
@@ -323,26 +336,30 @@ public void run() {
// store the max position of this entry retain
if (pendingAckMetadataEntry.getPendingAckOp() !=
PendingAckOp.ABORT
&& pendingAckMetadataEntry.getPendingAckOp()
!= PendingAckOp.COMMIT) {
+ logAppendTimes.incrementAndGet();
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 ->
-
metadataPositions.compute(PositionImpl.get(entry.getLedgerId(),
entry.getEntryId()),
- (thisPosition, otherPosition) -> {
- PositionImpl nowPosition =
PositionImpl
-
.get(pendingAckMetadata.getLedgerId(),
-
pendingAckMetadata.getEntryId());
- if (otherPosition == null) {
- return nowPosition;
- } else {
- return
nowPosition.compareTo(otherPosition) > 0 ? nowPosition
- : otherPosition;
- }
- }));
+ optional.ifPresent(pendingAckMetadata -> {
+ PositionImpl logPosition =
PositionImpl.get(entry.getLedgerId(), entry.getEntryId());
+ PositionImpl nowPosition =
PositionImpl.get(pendingAckMetadata.getLedgerId(),
+
pendingAckMetadata.getEntryId());
+
+ if (nowPosition.compareTo(maxAckPosition) > 0)
{
+ maxAckPosition = nowPosition;
+ }
+ if (logAppendTimes.get() >
upperLimitOfLogAppendTimes) {
+ pendingAckLogIndex.compute(maxAckPosition,
+ (thisPosition, otherPosition) ->
logPosition);
+ upperLimitOfLogAppendTimes =
logIndexBackoff.next(pendingAckLogIndex.size());
+ logAppendTimes.set(0);
+ }
Review Comment:
Maybe I need to pull them out as a method
--
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]