Closed sredxny closed 2 months ago
API Changes
no api changes detected
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪ |
🧪 No relevant tests |
🔒 No security concerns identified |
⚡ Key issues to review Error Handling Ensure that the `Done()` method is called in all code paths to prevent potential deadlocks or goroutine leaks if an error occurs before reaching the new placement of `connectionDialingWG.Done()`. |
Category | Suggestion | Score |
Possible bug |
Ensure proper handling of wait group decrement to avoid potential deadlocks or goroutine leaks___ **Ensure that theconnectionDialingWG.Done() is called even if an error occurs during the connection setup. This can be achieved by using a defer statement at the beginning of the connection setup block.** [rpc/rpc_client.go [298-302]](https://github.com/TykTechnologies/tyk/pull/6574/files#diff-3b88914c99bb9418e44e6389ce73579843562e8900730b380d7fff2e95c51033R298-R302) ```diff +defer connectionDialingWG.Done() conn.Write([]byte("proto2")) conn.Write([]byte{byte(len(connID))}) conn.Write([]byte(connID)) -// only mark as done is connection is established -connectionDialingWG.Done() ``` Suggestion importance[1-10]: 9Why: The suggestion correctly identifies a potential issue where `connectionDialingWG.Done()` may not be called if an error occurs before the connection is fully established. Using `defer` ensures that the wait group is decremented regardless of the outcome, preventing potential deadlocks or goroutine leaks. This is a crucial improvement for the reliability of the connection handling logic. | 9 |
Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
/release to release-5-lts
Working on it! Note that it can take a few minutes.
@sredxny Succesfully merged PR
/release to release-5.3
/release to release-5.3
Working on it! Note that it can take a few minutes.
@sredxny Succesfully merged PR
/release to release-5.3.6
Working on it! Note that it can take a few minutes.
@sredxny Succesfully merged PR
/release to release-5.6
Working on it! Note that it can take a few minutes.
@sredxny Succesfully merged PR
/release to release-5.6.0
Working on it! Note that it can take a few minutes.
@sredxny Succesfully merged PR
User description
Description
When the gw is ran as edge we want this to wait until the connection is established with MDCB before attempting to pull policies and apis, we should only mark the connection waitgroup as done when the connection is successful not on every attempt
Related Issue
TT-13130
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
PR Type
Bug fix
Description
rpc_client.go
to ensure the waitgroup is marked as done only when a connection is successfully established.Done()
call from the defer statement and added it after the connection is confirmed.Changes walkthrough 📝
rpc_client.go
Fix waitgroup completion logic in connection establishment
rpc/rpc_client.go
Done()
call from the defer statement in theDial
function.Done()
call after the connection is successfully established.connection.