Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #7031] fix PoP caused broker memory leak bug #7032

Merged
merged 1 commit into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,16 @@ private boolean checkQueueOk(PopCheckPointWrapper pointWrapper) {
* @param nextBeginOffset
* @return
*/
public void addCkJustOffset(PopCheckPoint point, int reviveQueueId, long reviveQueueOffset, long nextBeginOffset) {
public boolean addCkJustOffset(PopCheckPoint point, int reviveQueueId, long reviveQueueOffset, long nextBeginOffset) {
PopCheckPointWrapper pointWrapper = new PopCheckPointWrapper(reviveQueueId, reviveQueueOffset, point, nextBeginOffset, true);

if (this.buffer.containsKey(pointWrapper.getMergeKey())) {
// when mergeKey conflict
// will cause PopBufferMergeService.scanCommitOffset cannot poll PopCheckPointWrapper
POP_LOGGER.warn("[PopBuffer]mergeKey conflict when add ckJustOffset. ck:{}, mergeKey:{}", pointWrapper, pointWrapper.getMergeKey());
return false;
}

this.putCkToStore(pointWrapper, !checkQueueOk(pointWrapper));

putOffsetQueue(pointWrapper);
Expand All @@ -440,6 +447,7 @@ public void addCkJustOffset(PopCheckPoint point, int reviveQueueId, long reviveQ
if (brokerController.getBrokerConfig().isEnablePopLog()) {
POP_LOGGER.info("[PopBuffer]add ck just offset, {}", pointWrapper);
}
return true;
}

public void addCkMock(String group, String topic, int queueId, long startOffset, long invisibleTime,
Expand Down Expand Up @@ -492,6 +500,13 @@ public boolean addCk(PopCheckPoint point, int reviveQueueId, long reviveQueueOff
return false;
}

if (this.buffer.containsKey(pointWrapper.getMergeKey())) {
// when mergeKey conflict
// will cause PopBufferMergeService.scanCommitOffset cannot poll PopCheckPointWrapper
POP_LOGGER.warn("[PopBuffer]mergeKey conflict when add ck. ck:{}, mergeKey:{}", pointWrapper, pointWrapper.getMergeKey());
return false;
}

putOffsetQueue(pointWrapper);
this.buffer.put(pointWrapper.getMergeKey(), pointWrapper);
this.counter.incrementAndGet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,9 @@ private CompletableFuture<Long> popMsgFromQueue(String attemptId, boolean isRetr
this.brokerController.getConsumerOffsetManager().commitOffset(channel.remoteAddress().toString(),
requestHeader.getConsumerGroup(), topic, queueId, finalOffset);
} else {
appendCheckPoint(requestHeader, topic, reviveQid, queueId, finalOffset, result, popTime, this.brokerController.getBrokerConfig().getBrokerName());
if (!appendCheckPoint(requestHeader, topic, reviveQid, queueId, finalOffset, result, popTime, this.brokerController.getBrokerConfig().getBrokerName())) {
return atomicRestNum.get() + result.getMessageCount();
}
}
ExtraInfoUtil.buildStartOffsetInfo(startOffsetInfo, isRetry, queueId, finalOffset);
ExtraInfoUtil.buildMsgOffsetInfo(msgOffsetInfo, isRetry, queueId,
Expand Down Expand Up @@ -685,7 +687,7 @@ public final MessageExtBrokerInner buildCkMsg(final PopCheckPoint ck, final int
return msgInner;
}

private void appendCheckPoint(final PopMessageRequestHeader requestHeader,
private boolean appendCheckPoint(final PopMessageRequestHeader requestHeader,
final String topic, final int reviveQid, final int queueId, final long offset,
final GetMessageResult getMessageTmpResult, final long popTime, final String brokerName) {
// add check point msg to revive log
Expand All @@ -708,10 +710,9 @@ private void appendCheckPoint(final PopMessageRequestHeader requestHeader,
);

if (addBufferSuc) {
return;
return true;
}

this.popBufferMergeService.addCkJustOffset(
return this.popBufferMergeService.addCkJustOffset(
ck, reviveQid, -1, getMessageTmpResult.getNextBeginOffset()
);
}
Expand Down