Skip to content

Commit d254f79

Browse files
authored
[ISSUE #10071] Fix PopLiteLongPollingService#cleanUnusedResource
Problem: The cleanUnusedResource method was cleaning up client long polling requests without returning results to clients, causing client errors. Solution: 1. Simplified the cleanUnusedResource method to only remove entries with empty request queues 2. Changed cleanup interval from 5 minutes to 3 minutes Change-Id: If7052ba0d088e68cf654e6b7efafe09f5fa877be
1 parent c2c674d commit d254f79

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

broker/src/main/java/org/apache/rocketmq/broker/longpolling/PopLiteLongPollingService.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.apache.rocketmq.broker.BrokerController;
2727
import org.apache.rocketmq.common.ServiceThread;
2828
import org.apache.rocketmq.common.constant.LoggerName;
29-
import org.apache.rocketmq.common.lite.LiteSubscription;
3029
import org.apache.rocketmq.logging.org.slf4j.Logger;
3130
import org.apache.rocketmq.logging.org.slf4j.LoggerFactory;
3231
import org.apache.rocketmq.remoting.netty.NettyRemotingAbstract;
@@ -126,7 +125,7 @@ public void run() {
126125
}
127126

128127
// clean unused
129-
if (lastCleanTime == 0 || System.currentTimeMillis() - lastCleanTime > 5 * 60 * 1000) {
128+
if (lastCleanTime == 0 || System.currentTimeMillis() - lastCleanTime > 3 * 60 * 1000) {
130129
cleanUnusedResource();
131130
}
132131
} catch (Throwable e) {
@@ -247,10 +246,8 @@ public PollingResult polling(final ChannelHandlerContext ctx, RemotingCommand re
247246
private void cleanUnusedResource() {
248247
try {
249248
pollingMap.entrySet().removeIf(entry -> {
250-
String clientId = entry.getKey(); // see getPollingKey()
251-
LiteSubscription subscription = brokerController.getLiteSubscriptionRegistry().getLiteSubscription(clientId);
252-
if (null == subscription || CollectionUtils.isEmpty(subscription.getLiteTopicSet())) {
253-
LOGGER.info("clean polling structure of {}", clientId);
249+
if (CollectionUtils.isEmpty(entry.getValue())) {
250+
LOGGER.info("clean polling structure of {}", entry.getKey()); // see getPollingKey()
254251
return true;
255252
}
256253
return false;

0 commit comments

Comments
 (0)