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: fix the bug that the redirection signal may be discarded #75

Merged
merged 2 commits into from
Sep 5, 2022

Conversation

djshow832
Copy link
Collaborator

What problem does this PR solve?

Issue Number: close None

Problem Summary:
Some test cases are unstable, such as TestNormalRedirect(https://github.com/pingcap/TiProxy/runs/8181135325?check_suite_focus=true) and TestRedirectFail.

Reason:
This is a bug introduced by #72. It doesn't only happen in testing.
Since BackendConnManager.processSignals also handles mgr.redirectResCh now, this may happen:

  • The process signal goroutine is executing notifyRedirectResult() and calls OnRedirectSucceed().
  • The router sees that the redirection succeeds and sends another redirection signal immediately.
  • The process signal goroutine is just returning from notifyRedirectResult() but does not go to the select-case yet.
  • BackendConnManager.Redirect is a non-blocking function but the size of channel signalReceived is 0, it discards the signal because it needs to wait.
  • The redirection signal is never sent but the router thought it had, thus the connection will never finish redirection.

What is changed and how it works:
Actually, doing one of these modifications is enough, but I modified them both to be more secure:

  • Change the size of channel signalReceived to 1.
  • Never discard the redirection signal.

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

Release note

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

None

@xhebox xhebox merged commit ddf7bfb into pingcap:main Sep 5, 2022
@djshow832 djshow832 deleted the fix_redirect_signal branch September 5, 2022 06:05
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