rocketmq icon indicating copy to clipboard operation
rocketmq copied to clipboard

[Bug] Invalid key/value in long polling is not removed from Map

Open yx9o opened this issue 1 year ago • 4 comments

Before Creating the Bug Report

  • [X] I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • [X] I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • [X] I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.

Runtime platform environment

mac

RocketMQ version

master

JDK Version

jdk1.8

Describe the Bug

Invalid Consumer data in org.apache.rocketmq.broker.longpolling.PullRequestHoldService#pullRequestTable will not be removed

image image

Steps to Reproduce

  1. Start Broker
  2. Create a Topic and send a message
  3. Start Consumer. When the pull message returns ResponseCode.PULL_NOT_FOUND, it will be added to org.apache.rocketmq.broker.longpolling.PullRequestHoldService#pullRequestTable
  4. But when the Consumer is stopped, the data in org.apache.rocketmq.broker.longpolling.PullRequestHoldService#pullRequestTable still exists

What Did You Expect to See?

After Consumer is stopped, the matching data in org.apache.rocketmq.broker.longpolling.PullRequestHoldService#pullRequestTable is removed

What Did You See Instead?

After Consumer is stopped, the matching data in org.apache.rocketmq.broker.longpolling.PullRequestHoldService#pullRequestTable is still there

Additional Context

We should remove key under the condition that null == mpr || null == mpr.cloneListAndClear()

yx9o avatar Oct 19 '23 09:10 yx9o

Hi @RongtongJin , please help check it.

yx9o avatar Oct 19 '23 09:10 yx9o

这个未删除的问题会带来哪些影响呢

joeCarf avatar Oct 20 '23 02:10 joeCarf

There may be problems in the following aspects:

  1. org.apache.rocketmq.broker.longpolling.PullRequestHoldService#pullRequestTable is getting larger and larger, which may lead to insufficient memory or even OOM
  2. Useless traversal and useless acquisition getMaxOffsetInQueue

yx9o avatar Oct 20 '23 04:10 yx9o

@lizhanhui What you think?

yp969803 avatar Dec 16 '23 15:12 yp969803