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

test: fix flaky TestAlterAddConstraintStateChange3 #48131

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

jiyfhust
Copy link
Contributor

What problem does this PR solve?

Issue Number: close #48123

Problem Summary:

There seems a race between:

https://github.com/pingcap/tidb/blob/3894bc5232183d8107482cae4f6c121a71478cb8/pkg/ddl/constraint_test.go#L239C43-L239C43

and

https://github.com/pingcap/tidb/blob/3894bc5232183d8107482cae4f6c121a71478cb8/pkg/ddl/constraint_test.go#L247C1-L247C1

The reason is:

  1. When model.StatePublic, L245 "alter table t add constraint c3 check ( a > 10)" return, and go on L246、L247.
  2. However,the Hook set local constraint state to model.StateWriteReorganization at L234.
  3. if L247 go faster than Hook L239,it will read the the not public state,then error occur.

How to reproduce:
before Hook L239, we add a line "time.Sleep(50 * time.Millisecond)" to make the race more competitive, then run the tests.

What is changed and how it works?

Sleep 50ms after add constraints to wait Hook finish. 50ms is enough generally for the simple sql "insert into t values(1)".

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

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

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

None

@ti-chi-bot ti-chi-bot bot added 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. labels Oct 31, 2023
@tiprow
Copy link

tiprow bot commented Oct 31, 2023

Hi @jiyfhust. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jiyfhust
Copy link
Contributor Author

/cc @hawkingrei @CbcWestwolf @fzzf678

@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 31, 2023
@codecov
Copy link

codecov bot commented Oct 31, 2023

Codecov Report

Merging #48131 (46b7cfa) into master (30288c7) will increase coverage by 1.1670%.
Report is 20 commits behind head on master.
The diff coverage is n/a.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #48131        +/-   ##
================================================
+ Coverage   71.6145%   72.7816%   +1.1670%     
================================================
  Files          1401       1423        +22     
  Lines        405923     412284      +6361     
================================================
+ Hits         290700     300067      +9367     
+ Misses        95448      93305      -2143     
+ Partials      19775      18912       -863     
Flag Coverage Δ
integration 42.3702% <ø> (?)
unit 71.5792% <ø> (-0.0354%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 54.0503% <ø> (ø)
parser ∅ <ø> (∅)
br 48.6459% <ø> (-4.2749%) ⬇️

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 31, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 31, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-10-31 06:39:43.306302313 +0000 UTC m=+2935180.893412458: ☑️ agreed by hawkingrei.
  • 2023-10-31 06:46:36.996369051 +0000 UTC m=+2935594.583479191: ☑️ agreed by fzzf678.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 31, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CbcWestwolf, fzzf678, hawkingrei

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:
  • OWNERS [CbcWestwolf,hawkingrei]

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

@jiyfhust
Copy link
Contributor Author

/test mysql-test

@tiprow
Copy link

tiprow bot commented Oct 31, 2023

@jiyfhust: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test mysql-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jiyfhust
Copy link
Contributor Author

/test mysql-test

@tiprow
Copy link

tiprow bot commented Oct 31, 2023

@jiyfhust: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test mysql-test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@jiyfhust
Copy link
Contributor Author

/ok-to-test

@ti-chi-bot ti-chi-bot bot added the ok-to-test Indicates a PR is ready to be tested. label Oct 31, 2023
@hawkingrei
Copy link
Member

/retest

@ti-chi-bot ti-chi-bot bot merged commit de6ebc0 into pingcap:master Oct 31, 2023
@jiyfhust jiyfhust deleted the fix_constraints_test branch October 31, 2023 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm ok-to-test Indicates a PR is ready to be tested. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flaky test TestAlterAddConstraintStateChange3
4 participants