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

server: fix a unstable test TestInitConnect #30250

Closed
wants to merge 4 commits into from

Conversation

tiancaiamao
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #30249

Problem Summary:

[2021-11-30T02:29:26.743Z] --- FAIL: TestInitConnect (1.36s)
[2021-11-30T02:29:26.743Z]     dbtestkit.go:72:
[2021-11-30T02:29:26.743Z]              Error Trace:    dbtestkit.go:72
[2021-11-30T02:29:26.743Z]                                                      server_test.go:1939
[2021-11-30T02:29:26.743Z]                                                      server_test.go:117
[2021-11-30T02:29:26.743Z]                                                      server_test.go:1938
[2021-11-30T02:29:26.743Z]                                                      tidb_test.go:1107
[2021-11-30T02:29:26.743Z]              Error:          Received unexpected error:
[2021-11-30T02:29:26.743Z]                              commands out of sync. Did you run multiple statements at once?
[2021-11-30T02:29:26.743Z]              Test:           TestInitConnect
[2021-11-30T02:29:26.743Z]              Messages:       sql:SET GLOBAL init_connect="insert into test.ts VALUES (NOW());SET @a=1;", args:[]
[2021-11-30T02:29:26.743Z]     server_test.go:112:
[2021-11-30T02:29:26.743Z]              Error Trace:    server_test.go:112
[2021-11-30T02:29:26.743Z]                                                      panic.go:613
[2021-11-30T02:29:26.743Z]                                                      testing.go:741
[2021-11-30T02:29:26.743Z]                                                      dbtestkit.go:72
[2021-11-30T02:29:26.743Z]                                                      server_test.go:1939
[2021-11-30T02:29:26.743Z]                                                      server_test.go:117
[2021-11-30T02:29:26.743Z]                                                      server_test.go:1938
[2021-11-30T02:29:26.743Z]                                                      tidb_test.go:1107
[2021-11-30T02:29:26.743Z]              Error:          Received unexpected error:
[2021-11-30T02:29:26.743Z]                              bad connection
[2021-11-30T02:29:26.743Z]              Test:           TestInitConnect

What is changed and how it works?

commands out of sync. Did you run multiple statements at once?

Check List

Tests

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

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Nov 30, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • djshow832
  • xhebox

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the release-note-none Denotes a PR that doesn't merit a release note. label Nov 30, 2021
@ti-chi-bot ti-chi-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 30, 2021
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Nov 30, 2021
@hawkingrei
Copy link
Member

/run-check_dev

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Nov 30, 2021
@djshow832
Copy link
Contributor

Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 60 near ""insert into test.ts VALUES (NOW());"

server/server_test.go Outdated Show resolved Hide resolved
@bb7133
Copy link
Member

bb7133 commented Nov 30, 2021

I suspect there is something wrong with the parallel execution of test case:

> commands out of sync. Did you run multiple statements at once?

Which looks similiar to #30286

@tiancaiamao
Copy link
Contributor Author

/hold

@ti-chi-bot ti-chi-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 30, 2021
@tiancaiamao
Copy link
Contributor Author

The change seems to be incorrect.

The sql should be written as SET GLOBAL init_connect="insert into test.ts VALUES (NOW());SET @a=1;"
This is a feature introduced in #23713, tidb will check the init_connect variable and execute the corresponding SQL for new incomming connection.

And the PR is merged in Mar 31 ... for a long I never see such fail in CI,
so I believe it might be related to the restruct of the test case #29535

There isn't much information in the error log, if it happens again I'll take a close look.

@djshow832
Copy link
Contributor

I suspect there is something wrong with the parallel execution of test case:

> commands out of sync. Did you run multiple statements at once?

Which looks similiar to #30286

Agreed. Before migrating to testify, both TestGetIndexMVCC and TestInitConnect ran serially, but now they run in parallel and this kind of error happens frequently.

@bb7133
Copy link
Member

bb7133 commented Dec 1, 2021

Agreed. Before migrating to testify, both TestGetIndexMVCC and TestInitConnect ran serially.

Looks that we have to change them back.

@bb7133
Copy link
Member

bb7133 commented Dec 1, 2021

@djshow832
Copy link
Contributor

djshow832 commented Dec 1, 2021

But I still have not figured out why running in parallel could cause this problem. Each Server runs separately with different ports in each tidbTestSuite and should not disturb other servers. :-(

commands out of sync. Did you run multiple statements at once? is thrown from the go-sql-driver and is not caused by running multiple statements most of the time, according to the discussion in go-sql-driver/mysql#314 .

@mjonss
Copy link
Contributor

mjonss commented Dec 1, 2021

Could it be that the error really is 'bad connection'? I.e. there were some issue when connecting, which did not get handled properly?

[2021-11-30T02:29:26.743Z]              Error:          Received unexpected error:
[2021-11-30T02:29:26.743Z]                              bad connection

@mjonss
Copy link
Contributor

mjonss commented Dec 1, 2021

I would suggest to add a db.Ping() right after the sql.Open() in runTests, to be sure the connection is working (Open does only open/create the handle, it does not actually connect yet).

@djshow832
Copy link
Contributor

There is already a PR #30306

@tiancaiamao tiancaiamao closed this Dec 2, 2021
@tiancaiamao tiancaiamao deleted the ci-30249 branch December 2, 2021 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unstable test found in CI TestInitConnect
7 participants