-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][test] Fix ConcurrentModificationException in Ipv4Proxy #24632
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
Conversation
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great description and thanks for addressing this!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #24632 +/- ##
============================================
+ Coverage 73.56% 74.24% +0.68%
- Complexity 32894 33153 +259
============================================
Files 1882 1882
Lines 146854 146854
Branches 16866 16866
============================================
+ Hits 108030 109035 +1005
+ Misses 30153 29157 -996
+ Partials 8671 8662 -9
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
(cherry picked from commit 19b7c27)
(cherry picked from commit 19b7c27)
(cherry picked from commit 19b7c27)
Fixes #24627
Motivation
As shared in #24627, ZkSessionExpireTest is flaky. In the cleanup method, the main thread tries to close a PulsarService but then remains in WAITING state, and the test runs into the one hour timeout.
The logs shared in the issue contain a ConcurrentModificationException:
The ZkSessionExpireTest calls
Ipv4Proxy.disconnectFrontChannels()to inject a ZK session expire error:The method
disconnectFrontChannels()looks as follows:When
channel.close()is called, it triggersFrontendHandler.channelInactive(), which removes the channel from thefrontChannelslist:This can trigger the ConcurrentModificationException.
If the ConcurrentModificationException is thrown, the test execution stops. We don't reach the point of the test where the
rejectAllConnectionsis reverted. Therefore, the cleanup method cannot close the PulsarService properly.I was able to replicate the ConcurrentModificationException by inserting a
Thread.sleep()intodisconnectFrontChannels():Modifications
Prevent ConcurrentModificationException by iterating over a copy of
frontChannels.Verifying this change
When adding the
Thread.sleep(), the ConcurrentModificationException was always thrown. After changing the for-loop to iterate over a copy offrontChannels, even with theThread.sleep(), no ConcurrentModificationException occurs.Does this pull request potentially affect one of the following parts:
Documentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: pdolif#13