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

Improve tablet types to wait #17622

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ejortegau
Copy link
Contributor

Description

This PR improves handling of vtgate --tablet_types_to_wait so that timeouts waiting for tablets are interpreted
as not having successfully gotten healthchecks for all tablet types in all keyspaces of interest, leading to
retries instead of simply logging the error and continuing.

Related Issue(s)

#17412

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

Deployment Notes

N/A

Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
Copy link
Contributor

vitess-bot bot commented Jan 24, 2025

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 Jan 24, 2025
@github-actions github-actions bot added this to the v22.0.0 milestone Jan 24, 2025
Copy link

codecov bot commented Jan 24, 2025

Codecov Report

Attention: Patch coverage is 0% with 15 lines in your changes missing coverage. Please review.

Project coverage is 67.77%. Comparing base (fd1186c) to head (f96ba9f).
Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtgate/vtgate.go 0.00% 14 Missing ⚠️
go/vt/vtgate/tabletgateway.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17622      +/-   ##
==========================================
+ Coverage   67.75%   67.77%   +0.02%     
==========================================
  Files        1586     1587       +1     
  Lines      255726   255813      +87     
==========================================
+ Hits       173261   173383     +122     
+ Misses      82465    82430      -35     

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

Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
The test needed an extra tablet because the vtgate start-up script is waiting
for primary and replica, but we were only provisioning primary.

Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
@@ -30,8 +30,10 @@ fi
CELL=zone1 ../common/scripts/vtctld-up.sh

# start unsharded keyspace and tablet
CELL=zone1 TABLET_UID=100 ../common/scripts/mysqlctl-up.sh
SHARD=0 CELL=zone1 KEYSPACE=main TABLET_UID=100 ../common/scripts/vttablet-up.sh
for T_UID in 100 101; do
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need two tablets here because the vtgate start-up script waits for primary,replica and with a single tablet we end up with no replicas.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change vtgate to only wait for PRIMARY?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script that starts the vtgate (../common/vtgate-up.sh) is common for all tests, not only region_sharding, so changing it would affect all tests. It seemed less intrusive of a change to only have this test changed by having an extra vttablet. But if you prefer, I can do it that way. LMK.

Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
@harshit-gangal harshit-gangal added Breaking change release notes (needs details) This PR needs to be listed in the release notes in a dedicated section (deprecation notice, etc...) labels Feb 4, 2025
This reverts commit bc1d135.

Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
This test is no longer applicable as the vtgate won't start without tablets of the typs specified in --tablet_types_to_wait

Signed-off-by: Eduardo J. Ortega U. <5791035+ejortegau@users.noreply.github.com>
)

func TestLoadKeyspaceWithNoTablet(t *testing.T) {
Copy link
Contributor Author

@ejortegau ejortegau Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case was removed as discussed on Slack

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is an empty string an allowed value for --tablet_types_to_wait? Or do we validate and reject it and default to PRIMARY, REPLICA?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I understood that default is empty but it fails the validation, so at least one tablet type have to be provided.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I understood that default is empty but it fails the validation, so at least one tablet type have to be provided.

Correct, the vtgate refuses to start with empty string. Furthermore, it validates that the string corresponds to a serving tablet type.

@ejortegau ejortegau marked this pull request as ready for review February 5, 2025 09:51
Comment on lines +306 to +309
case errors.Is(err, context.DeadlineExceeded):
log.Warning("TabletGateway timed out waiting for tablets to become available - retrying.")

continue
Copy link
Member

@harshit-gangal harshit-gangal Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would require a new context for retry otherwise it will keep failing with context.DeadlineExceeded
we should add a test for this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure I follow what you would like the behavior to be, could you please elaborate? Thanks!

Copy link
Member

@harshit-gangal harshit-gangal Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check the parent context sent to WaitForTablets to ensure it is still valid. If the context has already expired, the retry will continue to fail with the same error.
The key decision here is whether we should stop retrying and fail or attempt again with a new context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking change 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 release notes (needs details) This PR needs to be listed in the release notes in a dedicated section (deprecation notice, etc...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants