fix: removal failure of freeConnection causing infinite loop#2171
Open
ksdaylight wants to merge 2 commits intosidorares:masterfrom
Open
fix: removal failure of freeConnection causing infinite loop#2171ksdaylight wants to merge 2 commits intosidorares:masterfrom
ksdaylight wants to merge 2 commits intosidorares:masterfrom
Conversation
Collaborator
|
Thanks @ksdaylight, 🙋🏻♂️ Is there a way to reproduce this error (through tests or a basic repro)? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request addresses a critical deadlock issue that arose from incorrect removal of connections in the _freeConnections list. The deadlock was caused by having different indices for the same connection instance, resulting in an infinite loop and CPU consumption reaching 100%.
Evidence of Issue
During debugging, I discovered that some different indices in the queue were pointing to the same connection, such as indices 0 and 3, 5 and 4, etc.(The provided text, omitting irrelevant repetitions:):
When instance 0 called the following code:
This logic set the connection's this._pool to null. Consequently, this also caused the _pool attribute of _freeConnections[3] to become null.
When
_removeIdleTimeoutConnectionsTimeris running with index 3, execute the same code as mentioned above.Here's where the problem occurred: since [3] and the original [0] were the same instance and [3]'s this._pool was null, it returned directly, leaving [3] in the _freeConnections list. This led to an infinite loop, causing the CPU consumption to spike to 100%.
Changes Made
Testing
I have run all the tests locally, and all of them passed successfully without any errors or failures. The detailed output of the tests is as follows: