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

[ISSUE #8366] Eliminate deadlocks during the client shutdown process. #8367

Merged
merged 3 commits into from
Jul 18, 2024

Conversation

YanYunyang
Copy link
Contributor

@YanYunyang YanYunyang commented Jul 5, 2024

… a channel, no longer acquire a read lock.

Which Issue(s) This PR Fixes

Fixes #8366

Brief Description

截屏2024-07-05 15 38 50

ChannelWrapper.getChannel() needs to hold the read lock. When determining if ChannelWrapper is the wrapper for a channel, no longer acquire a read lock.

…er for a channel, no longer acquire a read lock.
@drpmma
Copy link
Contributor

drpmma commented Jul 10, 2024

ChannelWrapper channelWrapper = this.channelWrapperTables.remove(channel);
if (channelWrapper != null && channelWrapper.tryClose(channel)) {
this.channelTables.remove(addrRemote);
}
LOGGER.info("closeChannel: the channel[{}] was removed from channel table", addrRemote);
RemotingHelper.closeChannel(channel);

It seems that this piece of code also may lead to deadlock.

Copy link
Contributor

@drpmma drpmma left a comment

Choose a reason for hiding this comment

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

There are two closeChannel method.

This piece of code also needs modification.

} else if (prevCW.getChannel() != channel) {
LOGGER.info("closeChannel: the channel[{}] has been closed before, and has been created again, nothing to do.",
addrRemote);
removeItemFromTable = false;
}

@YanYunyang
Copy link
Contributor Author

YanYunyang commented Jul 11, 2024

ChannelWrapper channelWrapper = this.channelWrapperTables.remove(channel);
if (channelWrapper != null && channelWrapper.tryClose(channel)) {
this.channelTables.remove(addrRemote);
}
LOGGER.info("closeChannel: the channel[{}] was removed from channel table", addrRemote);
RemotingHelper.closeChannel(channel);

It seems that this piece of code also may lead to deadlock.

Here is the same channelWrapper, and in the same thread. The lock in channelWrapper is reentrant.

@YanYunyang
Copy link
Contributor Author

There are two closeChannel method.

This piece of code also needs modification.

} else if (prevCW.getChannel() != channel) {
LOGGER.info("closeChannel: the channel[{}] has been closed before, and has been created again, nothing to do.",
addrRemote);
removeItemFromTable = false;
}

Here it needs to be changed to isWrapperOf to match the meaning. Thank you.

Copy link
Contributor

@drpmma drpmma left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 44.25%. Comparing base (77d6633) to head (36d561f).
Report is 5 commits behind head on develop.

Files Patch % Lines
...e/rocketmq/remoting/netty/NettyRemotingClient.java 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #8367      +/-   ##
=============================================
+ Coverage      43.88%   44.25%   +0.37%     
- Complexity     10647    10742      +95     
=============================================
  Files           1274     1274              
  Lines          88939    88941       +2     
  Branches       11432    11432              
=============================================
+ Hits           39033    39365     +332     
+ Misses         44985    44618     -367     
- Partials        4921     4958      +37     

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

Copy link
Contributor

@caigy caigy left a comment

Choose a reason for hiding this comment

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

LGTM

@RongtongJin RongtongJin merged commit 9115d66 into apache:develop Jul 18, 2024
9 of 10 checks passed
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.

[Bug] Multiple deadlocks were detected during the client shutdown process.
5 participants