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

Bug fix: Use target tablet from health stats cache when checking replication status #14436

Conversation

austenLacy
Copy link
Contributor

@austenLacy austenLacy commented Nov 2, 2023

Description

When determining which tablets to show in show vitess_replication_status Vitess is excluding tablets if their states were changed. This now uses the target tablet from the heath check cache which represents the expected state of the tablets.

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on the CI
  • Documentation was added or is not required

Deployment Notes

Copy link
Contributor

vitess-bot bot commented Nov 2, 2023

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 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 Nov 2, 2023
@github-actions github-actions bot added this to the v19.0.0 milestone Nov 2, 2023
@austenLacy austenLacy requested a review from deepthi as a code owner November 2, 2023 19:03
@austenLacy austenLacy force-pushed the austenlacy/fix-show-vitess-replication-status-bug branch from 126dd17 to f4920fe Compare November 2, 2023 20:24
@mattlord mattlord added Type: Bug Component: Query Serving Backport to: release-18.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 labels Nov 2, 2023
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks, @austenLacy ! ❤️

I only had a couple of minor comments -- let me know what you think. Have you already run the new test locally in a loop to check for flakiness?

I can come back to this quickly when I hear back.

go/test/endtoend/cluster/cluster_process.go Outdated Show resolved Hide resolved
func TestVtgateReplicationStatusCheckWithTabletTypeChange(t *testing.T) {
defer cluster.PanicHandler(t)
// Healthcheck interval on tablet is set to 1s, so sleep for 2s
time.Sleep(2 * time.Second)
Copy link
Contributor

@mattlord mattlord Nov 2, 2023

Choose a reason for hiding this comment

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

This is likely to be flaky in the CI due to unpredictable performance and occasional machine pauses. Any reason not to use the variable value (if we can access it) * 10 or something?

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 copied this from the other tests in this file. I can try running the test in a loop to see if it has any flakiness.

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 ran it 10 times in a loop 2-3 times and didn't see any flakiness.

for i in {1..10}; do go test -count=1 -timeout 30s -run ^TestVtgateReplicationStatusCheckWithTabletTypeChange$ vitess.io/vitess/go/test/endtoend/tabletgateway; sleep 1; done
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 23.902s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 25.247s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 23.130s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 23.091s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 25.394s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 25.882s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 23.308s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 23.246s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 25.528s
ok      vitess.io/vitess/go/test/endtoend/tabletgateway 25.797s

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Found one more issue that I think we should address after having looked at other usage of TabletsStats.

@deepthi could you please review this when you have time? No rush, but you know the healthcheck cache related code the best. Thanks!

@@ -901,7 +901,7 @@ func (e *Executor) showVitessReplicationStatus(ctx context.Context, filter *sqlp
for _, s := range status {
for _, ts := range s.TabletsStats {
// We only want to show REPLICA and RDONLY tablets
if ts.Tablet.Type != topodatapb.TabletType_REPLICA && ts.Tablet.Type != topodatapb.TabletType_RDONLY {
if ts.Target.TabletType != topodatapb.TabletType_REPLICA && ts.Target.TabletType != topodatapb.TabletType_RDONLY {
Copy link
Contributor

Choose a reason for hiding this comment

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

I did confirm that Target.TabletType is what's being used elsewhere when examining/showing the type for tablets in the healthcheck cache. So this part seems right.

Following on from that, I think that we should change all usage of ts.Tablet.* in this function to ts.Target.*. For example, below we should change ts.Tablet.Keyspace to ts.Target.Keyspace and ts.Tablet.Shard to ts.Target.Shard.

…r#showVitessReplicationStatus

Signed-off-by: Austen Lacy <[email protected]>
Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

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

Thanks, @austenLacy ! ❤️

Copy link
Member

@deepthi deepthi left a comment

Choose a reason for hiding this comment

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

Nice work on tests!

@@ -901,14 +901,14 @@ func (e *Executor) showVitessReplicationStatus(ctx context.Context, filter *sqlp
for _, s := range status {
for _, ts := range s.TabletsStats {
// We only want to show REPLICA and RDONLY tablets
if ts.Tablet.Type != topodatapb.TabletType_REPLICA && ts.Tablet.Type != topodatapb.TabletType_RDONLY {
if ts.Target.TabletType != topodatapb.TabletType_REPLICA && ts.Target.TabletType != topodatapb.TabletType_RDONLY {
Copy link
Member

Choose a reason for hiding this comment

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

It's actually worrisome that these two fields are not in sync. That is something we'll need to go back and review. Doesn't need to block this PR though.

@deepthi deepthi merged commit 366f7d2 into vitessio:main Nov 3, 2023
115 checks passed
vitess-bot pushed a commit that referenced this pull request Nov 3, 2023
…ication status (#14436)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
@austenLacy austenLacy deleted the austenlacy/fix-show-vitess-replication-status-bug branch November 3, 2023 20:08
austenLacy added a commit to Shopify/vitess that referenced this pull request Nov 6, 2023
…ication status (vitessio#14436)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
austenLacy added a commit to Shopify/vitess that referenced this pull request Nov 6, 2023
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
deepthi pushed a commit that referenced this pull request Nov 10, 2023
…n checking replication status (#14436) (#14456)

Signed-off-by: Austen Lacy <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
Co-authored-by: Austen Lacy <[email protected]>
Co-authored-by: Harshit Gangal <[email protected]>
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Feb 20, 2024
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Feb 20, 2024
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Mar 20, 2024
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
shanth96 pushed a commit to Shopify/vitess that referenced this pull request Mar 20, 2024
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
(cherry picked from commit f757ff2)
shivnagarajan pushed a commit to Shopify/vitess that referenced this pull request Mar 25, 2024
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
(cherry picked from commit f757ff2)
(cherry picked from commit 7fabb2d)
shivnagarajan pushed a commit to Shopify/vitess that referenced this pull request May 19, 2024
…ication status (vitessio#14436) (#128)

Signed-off-by: Austen Lacy <[email protected]>
Co-authored-by: Austen Lacy <[email protected]>
(cherry picked from commit f757ff2)
(cherry picked from commit 7fabb2d)
(cherry picked from commit a5cc396)
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.

Bug Report: Changing a tablet's type to REPLICA does not update results of SHOW vitess_replication_status
3 participants