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

[Bug] Client does not send heartbeats to all Nameserve in clustered mode, resulting in frequent disconnections #8358

Open
3 tasks done
weihubeats opened this issue Jul 3, 2024 · 0 comments

Comments

@weihubeats
Copy link
Member

Before Creating the Bug Report

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

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

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

Runtime platform environment

Ubuntu 22.04.2 LTS

RocketMQ version

5.1.0

JDK Version

1.8

Describe the Bug

Client does not send heartbeats to all Nameserve in clustered mode, resulting in frequent disconnections

Clients are timed to establish connections with all Nameserve
image

The client does not send a heartbeat to Nameserve regularly, but the client sets up idle read/write detection
image

The client will only get the topic metadata from one Nameserve at regular intervals, which can be treated as similar to a heartbeat, but in cluster mode, it will only get the metadata from a single Nameserve, which leads to frequent disconnections and reconnections of other Nameserves.

Steps to Reproduce

public class LocalProducer {

    /**
     * The number of produced messages.
     */
    public static final int MESSAGE_COUNT = 100;
    public static final String PRODUCER_GROUP = "xiao-zou-topic-producer";
    
    public static final String DEFAULT_NAMESRVADDR = "127.0.0.1:9000;127.0.0.1:9001;127.0.0.1:9002";
    public static final String TOPIC = "xiao-zou-topic";
    public static final String TAG = "TagA";
    private static final Log log = LogFactory.getLog(LocalProducer.class);

    public static void main(String[] args) throws MQClientException, InterruptedException {
        /*
         * Instantiate with a producer group name.
         */
        DefaultMQProducer producer = new DefaultMQProducer(PRODUCER_GROUP, true);
        producer.setNamesrvAddr(DEFAULT_NAMESRVADDR);
        producer.addRetryResponseCode(RemotingSysResponseCode.SYSTEM_BUSY);
        producer.start();

        for (int i = 0; i < MESSAGE_COUNT; i++) {
            try {
                Message msg = new Message(TOPIC /* Topic */,
                    TAG /* Tag */,
                    ("Hello xiaozou " + i).getBytes(RemotingHelper.DEFAULT_CHARSET) /* Message body */
                );
//                msg.setDelayTimeLevel(2);
                SendResult sendResult = producer.send(msg, 5000);
                DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
                System.out.printf("%s %s%n", sendResult, dtf2.format(LocalDateTime.now()));
                TimeUnit.SECONDS.sleep(20);
            } catch (Exception e) {
                e.printStackTrace();
                Thread.sleep(1000);
            }
        }
        producer.shutdown();
    }
}

image

What Did You Expect to See?

no error: NETTY CLIENT PIPELINE: IDLE exception

What Did You See Instead?

NETTY CLIENT PIPELINE: IDLE exception [127.0.0.1:9000]

Additional Context

No response

RongtongJin pushed a commit that referenced this issue Jul 4, 2024
…stered mode, resulting in frequent disconnections (#8359)

* Adding null does not update

* rolling back

* remove client scanAvailableNameSrv
YanYunyang added a commit to YanYunyang/rocketmq that referenced this issue Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant