Skip to content
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

Check mysqlConnector.canceled.Value when failed to TLS handshake #1615

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

yokonao
Copy link
Contributor

@yokonao yokonao commented Jul 31, 2024

Description

Check if the context is canceled when failed to TLS handshake.

fix: #1614

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary
  • Added myself / the copyright holder to the AUTHORS file

Summary by CodeRabbit

  • New Features

    • Added Nao Yokotsuka to the contributors list for improved project documentation.
  • Bug Fixes

    • Enhanced error handling in the TLS handshake process to better manage cancellation requests, improving connection responsiveness.

Copy link

coderabbitai bot commented Jul 31, 2024

Walkthrough

The recent changes enhance the project's error handling during connection establishment, specifically addressing scenarios where a context is canceled. A new check in the writeHandshakeResponsePacket function allows for early termination of the handshake process, improving responsiveness and reducing the likelihood of encountering "use of closed network connection" errors. Additionally, Nao Yokotsuka has been added to the contributors list, acknowledging their contributions to the project.

Changes

Files Change Summary
AUTHORS Added Nao Yokotsuka's name and email to the contributors list.
packets.go Modified writeHandshakeResponsePacket to include a check for a canceled context, improving error handling during TLS handshake.

Assessment against linked issues

Objective Addressed Explanation
Resolve "use of closed network connection" when context is canceled (#[1614])

🐇 In the code we hop with glee,
A check for cancel, oh so free!
Nao's name now shines bright and clear,
In the AUTHORS list, we cheer!
Bugs retreat, the flow is fine,
Let’s connect and sip some wine! 🍷


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 44553d6 and 20f446f.

Files selected for processing (2)
  • AUTHORS (1 hunks)
  • packets.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • AUTHORS
Additional comments not posted (1)
packets.go (1)

355-357: LGTM! But verify the function usage in the codebase.

The added check for context cancellation during the TLS handshake is a good improvement. The code changes are approved.

However, ensure that all function calls to writeHandshakeResponsePacket handle the new behavior correctly.

@coveralls
Copy link

Coverage Status

coverage: 82.385% (-0.02%) from 82.403%
when pulling 20f446f on yokonao:fix-use-closed-conn
into 44553d6 on go-sql-driver:master.

Copy link
Contributor

@shogo82148 shogo82148 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@shogo82148 shogo82148 merged commit c7276ee into go-sql-driver:master Aug 4, 2024
37 of 38 checks passed
@yokonao
Copy link
Contributor Author

yokonao commented Aug 6, 2024

@shogo82148

Thanks for your review!

We would like to apply this patch to our application, are there plans to release new version?

@yokonao yokonao deleted the fix-use-closed-conn branch August 6, 2024 03:10
methane pushed a commit to methane/mysql that referenced this pull request Nov 13, 2024
…sql-driver#1615)

### Description
Check if the context is canceled when failed to TLS handshake.

fix: go-sql-driver#1614

### Checklist
- [x] Code compiles correctly
- [x] Created tests which fail without the change (if possible)
- [x] All tests passing
- [x] Extended the README / documentation, if necessary
- [x] Added myself / the copyright holder to the AUTHORS file


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Added Nao Yokotsuka to the contributors list for improved project
documentation.
  
- **Bug Fixes**
- Enhanced error handling in the TLS handshake process to better manage
cancellation requests, improving connection responsiveness.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use of closed network connection occurs rarely when context is canceled during establishing a connection
3 participants