-
Notifications
You must be signed in to change notification settings - Fork 594
Reset connection deadline before connection is released #1608
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -44,7 +44,6 @@ func (c *connect) query(ctx context.Context, release nativeTransportRelease, que | |||||||||
// context level deadlines override any read deadline | ||||||||||
if deadline, ok := ctx.Deadline(); ok { | ||||||||||
c.conn.SetDeadline(deadline) | ||||||||||
defer c.conn.SetDeadline(time.Time{}) | ||||||||||
} | ||||||||||
|
||||||||||
if err = c.sendQuery(body, &options); err != nil { | ||||||||||
|
@@ -80,6 +79,8 @@ func (c *connect) query(ctx context.Context, release nativeTransportRelease, que | |||||||||
} | ||||||||||
close(stream) | ||||||||||
close(errors) | ||||||||||
|
||||||||||
c.conn.SetDeadline(time.Time{}) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This unconditional reset will clear any pre-existing deadlines—even if none were set for this query—which may unintentionally override other timeouts. Track whether you applied a context deadline and guard the reset accordingly.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we might need to do this for p.s. thanks for jumping on this so quickly! |
||||||||||
release(c, err) | ||||||||||
}() | ||||||||||
|
||||||||||
|
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.
If a deadline was set on the connection, it isn't cleared when
sendQuery
returns an error, which can leave a stale deadline on subsequent operations. Consider usingdefer
immediately after setting the deadline or explicitly clearing it in this error path.Copilot uses AI. Check for mistakes.