You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix incorrect use of connection ctx during remote run. - #17002
fix a bug that the TCP context was incorrectly used as a STREAM context during the remote run,
this will cause an inability to properly determine whether the stream had been disconnected.
PR Type
Bug fix
Description
Added SessionCtx method to clientSession and ClientSession interface to retrieve the session context.
Replaced incorrect usage of ctx with connectionCtx and messageCtx in remoterunServer.go.
Updated messageReceiverOnServer struct and related functions to properly handle connection and message contexts.
Changes walkthrough 📝
Relevant files
Enhancement
server.go
Add method to retrieve session context in client session
pkg/common/morpc/server.go
Added SessionCtx method to clientSession to return the session context.
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.
PR Reviewer Guide 🔍
⏱️ Estimated effort to review [1-5]
3
🧪 Relevant tests
No
🔒 Security concerns
No
⚡ Key issues to review
Context Handling: The changes in context handling from a single context to separate messageCtx and connectionCtx are significant. Reviewers should ensure that the lifecycle and cancellation of these contexts are handled correctly across different parts of the application to avoid memory leaks or deadlocks.
Error Handling: The modification of error messages to use messageCtx instead of ctx needs careful review to ensure that the context used will still be active when errors are processed, thus avoiding any potential issues with using an expired context.
PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.
PR Code Suggestions ✨
Category
Suggestion
Score
Possible bug
Add a nil check for receiver.connectionCtx before using it in select statements to prevent potential runtime panics
To ensure that the receiver.connectionCtx is not nil when accessed, add a nil check before using it in the select statements. This will prevent potential runtime panics if connectionCtx is unexpectedly nil.
Why: Adding a nil check is crucial to prevent runtime panics due to a nil context, which is a significant issue in concurrent Go applications.
8
Possible issue
Add a check to ensure receiver.messageCtx is not nil before using it in error handling to prevent potential nil pointer dereferences
To ensure that the error message context is always available, add a check to verify that receiver.messageCtx is not nil before using it in error handling.
-return nil, moerr.NewInternalError(receiver.messageCtx, "get dispatch process by uuid timeout")+if receiver.messageCtx != nil {+ return nil, moerr.NewInternalError(receiver.messageCtx, "get dispatch process by uuid timeout")+}+return nil, moerr.NewInternalError(context.Background(), "get dispatch process by uuid timeout")
Apply this suggestion
Suggestion importance[1-10]: 8
Why: This suggestion correctly addresses a potential nil pointer dereference, which is a critical issue that could crash the application at runtime.
8
Best practice
Add a deferred call to the cancel function when creating a new context with context.WithCancel to avoid potential memory leaks
When creating a new context with context.WithCancel, ensure that the cancel function is called to avoid potential memory leaks. Add a deferred call to runningCancel after creating the context.
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
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.
User description
What type of PR is this?
Which issue(s) this PR fixes:
https://github.com/matrixorigin/MO-Cloud/issues/3542
https://github.com/matrixorigin/MO-Cloud/issues/2788
https://github.com/matrixorigin/MO-Cloud/issues/3281
What this PR does / why we need it:
fix a bug that the TCP context was incorrectly used as a STREAM context during the remote run,
this will cause an inability to properly determine whether the stream had been disconnected.
PR Type
Bug fix
Description
SessionCtxmethod toclientSessionandClientSessioninterface to retrieve the session context.ctxwithconnectionCtxandmessageCtxinremoterunServer.go.messageReceiverOnServerstruct and related functions to properly handle connection and message contexts.Changes walkthrough 📝
server.go
Add method to retrieve session context in client sessionpkg/common/morpc/server.go
SessionCtxmethod toclientSessionto return the sessioncontext.
types.go
Add session context retrieval method to ClientSession interfacepkg/common/morpc/types.go
SessionCtxmethod toClientSessioninterface.remoterunServer.go
Fix incorrect context usage in remote run serverpkg/sql/compile/remoterunServer.go
ctxwithconnectionCtxandmessageCtxin variousfunctions.
messageReceiverOnServerstruct to includeconnectionCtxandmessageCtx.newMessageReceiverOnServerto initializeconnectionCtxusingSessionCtx.messageCtx.