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

Flakes: Address flakes in TestMoveTables* unit tests #16942

Merged
merged 1 commit into from
Oct 14, 2024

Conversation

mattlord
Copy link
Contributor

@mattlord mattlord commented Oct 13, 2024

Description

Since #16583 we've seen the TestMoveTablesUnsharded and TestMoveTablesSharded tests become flaky. Especially the Sharded one.

The only directly relevant change made to these unit tests in that PR is adding the vrdbClient.Reset() call. That call however is not safe as it modifies the members while holding a mutex, most notably the done channel. The problem, however, is that we explicitly and intentionally do not take that mutex in the Wait() function, which is the primary user of that channel.

It's not 100% clear that this was the cause of the flakiness, but given that it was the only directly relevant change, we know it's unsafe, and CI failures that I saw (I was unable to repeat the test failures locally) seemed to indicate a repeated panic->recover cycle in the TabletManager which could be caused by unsafe channel manipulation:

ok  	vitess.io/vitess/go/vt/vttablet/tabletconn	1.035s
W1009 13:10:59.004444   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.005626   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.026628   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.027266   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
E1009 13:10:59.057000   47317 server.go:959] buildTrafficSwitcher failed: no streams found in keyspace sourceks for testwf
--- FAIL: TestMoveTablesSharded (0.03s)

...

W1009 13:10:59.058921   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.059540   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.076345   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.077371   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.

...
E1009 13:10:59.179155   47317 dbclient.go:134] error in stream 1, will retry after 5s: no schema defined
W1009 13:10:59.179357   47317 controller.go:197] context canceled: no schema defined
W1009 13:10:59.180705   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.181630   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.189298   47317 controller.go:187] context canceled: no schema defined
W1009 13:10:59.190224   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
W1009 13:10:59.190957   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.
E1009 13:10:59.200891   47317 dbclient.go:134] error in stream 1, will retry after 5s: no schema defined
W1009 13:10:59.202169   47317 controller.go:187] context canceled: no schema defined
W1009 13:10:59.203078   47317 controller.go:197] context canceled: no schema defined
W1009 13:10:59.204084   47317 controller.go:187] context canceled: no schema defined
W1009 13:10:59.205748   47317 log.go:39] Failed to read in config : Config File "vtconfig" Not Found in "[/opt/actions-runner/_work/vitess-private/vitess-private/go/vt/vttablet/tabletmanager]". This is optional, and can be ignored if you are not using config files. For a detailed explanation, see https://github.com/vitessio/vitess/blob/main/doc/viper/viper.md#config-files.

...

The Reset() function was being called for every shard, so that would also explain why the Sharded test was much more flaky than the Unsharded one.

Given all of this AND the fact that using this Reset() function is wholly unnecessary we remove its usage in this PR. We will then have to see how much this helps the somewhat random flakiness we've seen in the coming weeks.

While here, I also added mutex usage to the fakeTMClient methods that weren't already using it so that we should be concurrent safe if we start doing more tests in parallel in the future.

unit_race test re-runs can be seen here: https://github.com/vitessio/vitess/actions/runs/11317748149/job/31471559199?pr=16942

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added or is not required

Stop unnecessarily calling vrdbclient.Reset.
And use mutex to protect fakeTMClient members.

Signed-off-by: Matt Lord <[email protected]>
Copy link
Contributor

vitess-bot bot commented Oct 13, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Oct 13, 2024
@github-actions github-actions bot added this to the v22.0.0 milestone Oct 13, 2024
@mattlord mattlord changed the title Flakes: Address flakes in TestMoveTables* Flakes: Address flakes in TestMoveTables* unit tests Oct 13, 2024
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.40%. Comparing base (f0062e6) to head (c14175c).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16942      +/-   ##
==========================================
- Coverage   69.41%   69.40%   -0.02%     
==========================================
  Files        1570     1570              
  Lines      203948   203942       -6     
==========================================
- Hits       141576   141542      -34     
- Misses      62372    62400      +28     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattlord mattlord added Backport to: release-21.0 Needs to be backport to release-21.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Oct 14, 2024
@mattlord mattlord marked this pull request as ready for review October 14, 2024 03:45
@vitess-bot vitess-bot mentioned this pull request Oct 14, 2024
35 tasks
@mattlord mattlord merged commit 8b37c52 into vitessio:main Oct 14, 2024
104 of 112 checks passed
@mattlord mattlord deleted the mt_sharded_flakes branch October 14, 2024 17:07
vitess-bot pushed a commit that referenced this pull request Oct 14, 2024
frouioui pushed a commit that referenced this pull request Oct 14, 2024
…16942) (#16951)

Signed-off-by: Matt Lord <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
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.

3 participants