Skip to content

optimize: optimize client reconnect scheduling - #8199

Open
Anon2Tokyo wants to merge 2 commits into
apache:2.xfrom
Anon2Tokyo:optimize-client-reconnect-scheduling
Open

optimize: optimize client reconnect scheduling#8199
Anon2Tokyo wants to merge 2 commits into
apache:2.xfrom
Anon2Tokyo:optimize-client-reconnect-scheduling

Conversation

@Anon2Tokyo

Copy link
Copy Markdown

Ⅰ. Describe what this PR did

Optimize the RM/TM client reconnect scheduling in AbstractNettyRemotingClient.

The reconnect timer is now backed by a shared scheduled executor, and reconnect tasks are registered by transaction role. This avoids repeatedly scheduling reconnect tasks when clients with the same role are initialized.

A behavior test was added to verify that reconnect tasks are shared by transaction role and are only cancelled by the owner client.

Ⅱ. Does this pull request fix one issue?

fixes #5338

Ⅲ. Why don't you add test cases (unit test/integration test)?

Added unit coverage in NettyRemotingClientBehaviorTest.

Ⅳ. Describe how to verify it

mvn -pl core -am -Dtest=NettyRemotingClientBehaviorTest -DfailIfNoTests=false test

Ⅴ. Special notes for reviews

This change only shares the reconnect scheduler. The existing timerExecutor remains unchanged because it is also used by other timeout and cleanup tasks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves client reconnect scheduling to a shared, role-based executor and adds lifecycle coverage.

Changes:

  • Adds shared reconnect task registration and cancellation.
  • Adds a test for same-role task sharing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
AbstractNettyRemotingClient.java Implements shared reconnect scheduling.
NettyRemotingClientBehaviorTest.java Tests role-based task ownership.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +97 to +98
private static final ScheduledThreadPoolExecutor RECONNECT_EXECUTOR =
new ScheduledThreadPoolExecutor(1, new NamedThreadFactory("NettyClientReconnectTimer", true));
Comment on lines +152 to +154
ReconnectTaskHolder taskHolder = RECONNECT_TASKS.get(transactionRole);
if (taskHolder != null && !taskHolder.future.isCancelled() && !taskHolder.future.isDone()) {
return;
@funky-eyes funky-eyes added this to the 2.x Backlog milestone Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is it necessary that both the RM client and the TM client start a timer for reconnecting to seata server ?

4 participants