Skip to content

Conversation

@oxsean
Copy link
Contributor

@oxsean oxsean commented Aug 5, 2025

What is the purpose of the change?

Fix mistaken deletion of reconnect interval

@oxsean oxsean requested a review from Copilot August 5, 2025 03:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a mistaken deletion of the reconnect interval by restoring scheduled reconnection logic with proper timing control.

  • Replaces immediate doReconnect() call with scheduled doConnect() execution
  • Adds error handling and logging for connection failures during reconnection
  • Restores the use of reconnectDuration for controlling reconnection timing

connectivityExecutor.schedule(
() -> {
try {
doConnect();
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The change from doReconnect() to doConnect() may alter the reconnection behavior. doReconnect() likely contains reconnection-specific logic that differs from the initial connection logic in doConnect(). Consider verifying that doConnect() handles reconnection scenarios appropriately or restore the use of doReconnect().

Suggested change
doConnect();
doReconnect();

Copilot uses AI. Check for mistakes.
@codecov-commenter
Copy link

codecov-commenter commented Aug 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.03%. Comparing base (af2625c) to head (77f0cee).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #15613      +/-   ##
============================================
- Coverage     61.06%   61.03%   -0.03%     
+ Complexity    11693       12   -11681     
============================================
  Files          1909     1909              
  Lines         86783    86781       -2     
  Branches      13094    13095       +1     
============================================
- Hits          52994    52967      -27     
- Misses        28373    28395      +22     
- Partials       5416     5419       +3     
Flag Coverage Δ
integration-tests-java21 33.00% <55.55%> (+0.01%) ⬆️
integration-tests-java8 33.11% <55.55%> (+0.06%) ⬆️
samples-tests-java21 32.72% <0.00%> (-0.01%) ⬇️
samples-tests-java8 30.35% <0.00%> (-0.09%) ⬇️
unit-tests-java11 59.07% <100.00%> (-0.01%) ⬇️
unit-tests-java17 58.77% <100.00%> (-0.01%) ⬇️
unit-tests-java21 58.75% <100.00%> (-0.01%) ⬇️
unit-tests-java8 59.07% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@finefuture finefuture left a comment

Choose a reason for hiding this comment

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

I recommend making this change:

    protected void scheduleReconnect(long reconnectDuration, TimeUnit unit) {
        connectivityExecutor.schedule(() -> {
            try {
                doConnect();
            } catch (RemotingException e) {
                logger.error(
                        TRANSPORT_FAILED_RECONNECT, "", "", "Failed to reconnect to server: " + getConnectAddress());
            }
        }, reconnectDuration, unit);
    }

in ConnectionListener

        public void operationComplete(ChannelFuture future) {
            if (!isReconnecting.compareAndSet(true, false)) {
                return;
            }
            if (future.isSuccess()) {
                return;
            }
            AbstractNettyConnectionClient connectionClient = AbstractNettyConnectionClient.this;
            if (connectionClient.isClosed() || connectionClient.getCounter() == 0) {
                if (logger.isDebugEnabled()) {
                    logger.debug(
                            "Connection:{} aborted to reconnect. {}",
                            connectionClient,
                            future.cause().getMessage());
                }
                return;
            }
            if (logger.isDebugEnabled()) {
                logger.debug(
                        "Connection:{} is reconnecting, attempt=0 cause={}",
                        connectionClient,
                        future.cause().getMessage());
            }

            // Notify the connection is unavailable.
            disconnectedPromise.trySuccess(null);

            scheduleReconnect(reconnectDuration, TimeUnit.MILLISECONDS);
        }

in NettyConnectionHandler

    public void reconnect(Object channel) {
        if (!(channel instanceof Channel)) {
            return;
        }
        Channel nettyChannel = ((Channel) channel);
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Connection:{} is reconnecting, attempt={}", connectionClient, 1);
        }
        if (connectionClient.isClosed()) {
            LOGGER.info("The connection {} has been closed and will not reconnect", connectionClient);
            return;
        }
        connectionClient.scheduleReconnect(1, TimeUnit.SECONDS);
    }

Copy link
Contributor

@finefuture finefuture left a comment

Choose a reason for hiding this comment

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

It would be great if we could delete this useless variable.

in org.apache.dubbo.remoting.transport.netty4.NettyConnectionHandler#reconnect

EventLoop eventLoop = nettyChannel.eventLoop();

Copy link
Contributor

@finefuture finefuture left a comment

Choose a reason for hiding this comment

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

LGTM.

@zrlw zrlw self-requested a review August 6, 2025 02:40
@zrlw zrlw merged commit 629baf7 into apache:3.3 Aug 6, 2025
61 of 62 checks passed
MoritzArena pushed a commit to MoritzArena/dubbo that referenced this pull request Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants