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

backend, net: make connection concurrency safe #232

Merged
merged 5 commits into from
Mar 5, 2023

Conversation

djshow832
Copy link
Collaborator

What problem does this PR solve?

Issue Number: ref #229

Problem Summary:
To make set timeout / keep alive concurrently with forwarding messages / TLS handshake, the mgr.backendIO and PacketIO.conn must be concurrency safe.

What is changed and how it works:

  • Make mgr.backendIO atomic
  • Add RWMutex to PacketIO.conn

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Notable changes

  • Has configuration change
  • Has HTTP API interfaces change (Don't forget to add the declarative for API)
  • Has tiproxyctl change
  • Other user behavior changes

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@djshow832 djshow832 requested a review from xhebox March 5, 2023 06:05
clientIO *pnet.PacketIO
// type *pnet.PacketIO. The backendIO may be written during redirection
// and be read in ExecuteCmd/Redirect/setTimeout/setKeepalive.
backendIO unsafe.Pointer
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use https://pkg.go.dev/sync/atomic#Pointer instead?

@xhebox xhebox merged commit 513b8f2 into pingcap:main Mar 5, 2023
xhebox pushed a commit to xhebox/TiProxy that referenced this pull request Mar 13, 2023
@djshow832 djshow832 deleted the atomic_backend branch September 2, 2023 06:48
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.

2 participants