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, logger: fix data race in UT #443

Merged
merged 7 commits into from
Jan 15, 2024
Merged

Conversation

djshow832
Copy link
Collaborator

@djshow832 djshow832 commented Jan 3, 2024

What problem does this PR solve?

Issue Number: close #442

Problem Summary:

  • Data race in TestLogConcurrently and TestMultiAddr
  • There are some other concurrency bugs when forcibly closing the SQLServer: closing may happen anytime, including before connecting, during executing / redirecting / graceful shutdown, or concurrently with another closing

What is changed and how it works:

  • Fix data race in TestLogConcurrently
  • Process all the non-atomic members in BackendConnMgr with a lock to avoid data race
  • Call all the interfaces in HandshakeHandler in a lock so that the interfaces are safe to read any data
  • Stop the checkBackendTicker before executing commands so that long queries won't lead to unnecessary check
  • Avoid overriding statusClosing with statusNotifyClose by replacing statusClose.Store with statusClose.CompareAndStore
  • Fast fail when the context is canceled or the connection is closing in BackendConnMgr so that force close won't block

Note:

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
  • Has tiproxyctl change
  • Other user behavior changes

Release note

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

None

@ti-chi-bot ti-chi-bot bot requested review from bb7133 and xhebox January 3, 2024 03:00
@ti-chi-bot ti-chi-bot bot added the size/L label Jan 3, 2024
@ti-chi-bot ti-chi-bot bot added size/XL and removed size/L labels Jan 3, 2024
@djshow832 djshow832 marked this pull request as draft January 3, 2024 12:27
@ti-chi-bot ti-chi-bot bot added size/L and removed size/XL labels Jan 4, 2024
@djshow832 djshow832 marked this pull request as ready for review January 4, 2024 03:00
@pingcap pingcap deleted a comment from ti-chi-bot bot Jan 4, 2024
Copy link

ti-chi-bot bot commented Jan 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xhebox

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the lgtm label Jan 15, 2024
Copy link

ti-chi-bot bot commented Jan 15, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-01-15 02:43:16.335155823 +0000 UTC m=+151037.899453529: ☑️ agreed by xhebox.

@ti-chi-bot ti-chi-bot bot added the approved label Jan 15, 2024
@ti-chi-bot ti-chi-bot bot merged commit 3c493b2 into pingcap:main Jan 15, 2024
5 checks passed
@djshow832 djshow832 deleted the data_race branch February 7, 2024 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix data race in UT
2 participants