Skip to content

vtorc: treat any /healthz response as reachable for IncapacitatedPrimary#19514

Draft
mhamza15 wants to merge 2 commits intovitessio:mainfrom
mhamza15:incapacitated-primary-network
Draft

vtorc: treat any /healthz response as reachable for IncapacitatedPrimary#19514
mhamza15 wants to merge 2 commits intovitessio:mainfrom
mhamza15:incapacitated-primary-network

Conversation

@mhamza15
Copy link
Collaborator

@mhamza15 mhamza15 commented Feb 27, 2026

Description

IncapacitatedPrimary currently considers only an HTTP status code 200 as "primary reachable", and will only perform a recovery in that case (to avoid acting during a network partition). Tablets' /healthz can return a 500 in the case they are not serving, which prevents a recovery from happening.

This changes the condition so that it considers any response as "primary reachable" and not just a 200. There is a case we've seen where a primary that could've been recovered through IncapacitatedPrimary would have likely been ignored as it was not serving at the time.

Edit:

This also makes another change to fix a flaky test: when I added --log-format text as the default for tests, I removed some logic in a vtorc test that was parsing vtorc logs to calculate the time it took for a recovery to happen. That caused the test to be flaky, so I've made two changes:

  • Updated the tint handler time format to 2026-02-27 17:46:41.123 UTC for two reasons: one is to make it more global friendly instead of the American-oriented old format 5:05 PM, and two is to add subsecond resolution for more accurate duration calculation.
  • Restored similar logic to TestDeadPrimaryRecoversImmediately (the flaky test) so that it parses the time from the logs again and calculated recovery duration that way.

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

Deployment Notes

AI Disclosure

`IncapacitatedPrimary` currently considers only an HTTP status code 200
as "primary reachable", and will only perform a recovery in that case
(to avoid acting during a network partition). Tablets' `/healthz` can
return a 500 in the case they are not serving, which prevents a recovery
from happening.

This changes the condition so that it considers any response as "primary
reachable" and not just a 200. There is a case we've seen where a
primary that could've been recovered through `IncapacitatedPrimary`
would have likely been ignored as it was not serving at the time.

Signed-off-by: Mohamed Hamza <mhamza@fastmail.com>
@mhamza15 mhamza15 self-assigned this Feb 27, 2026
@github-actions github-actions bot added this to the v24.0.0 milestone Feb 27, 2026
@mhamza15 mhamza15 changed the title vtorc: treat any /healthz response as reachable vtorc: treat any /healthz response as reachable for IncapacitatedPrimary Feb 27, 2026
@vitess-bot vitess-bot bot added NeedsWebsiteDocsUpdate What it says NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work 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 Feb 27, 2026
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 27, 2026

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.

@mhamza15 mhamza15 added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: VTOrc Vitess Orchestrator integration 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 Feb 27, 2026
}
defer resp.Body.Close()
return resp.StatusCode == http.StatusOK, nil
return true, nil
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to treat all of them as success? https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status Even 404?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

My opinion is that the main thing we're validating here is that the instance is reachable over the network, i.e. there is no network partition. From that lens, I don't think we should differentiate between any HTTP status codes. I think ideally, we would even switch to a TCP dial. But I think this is a simple middle-ground for now.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's reasonable. That did align with my original thinking for making the call.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mhamza15 / @mattlord until I guess recent PRs, VTOrc talked only gRPCs to tablets (pooled for efficiency)

I'm a bit confused why we're talking to a 2nd non-gRPC port on tablets, ie: /healthz, etc. We can cross/use-both ports if there's a strong reason, but I'm not following what it is

If we want to know if a tablet is up, I suggest we use PingTablet and not a 2nd port without pooled connections

Copy link
Member

Choose a reason for hiding this comment

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

I don't have a strong opinion here, but my thinking was that this simple HTTP request is a simpler and more direct way to confirm that we can simply talk to the process over the network. Fewer things involved.

Signed-off-by: Mohamed Hamza <mhamza@fastmail.com>
@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 0.00%. Comparing base (70c7a72) to head (3ce4b9a).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/log/flags.go 0.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (70c7a72) and HEAD (3ce4b9a). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (70c7a72) HEAD (3ce4b9a)
1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #19514       +/-   ##
===========================================
- Coverage   69.67%    0.00%   -69.68%     
===========================================
  Files        1614        3     -1611     
  Lines      216793      116   -216677     
===========================================
- Hits       151044        0   -151044     
+ Misses      65749      116    -65633     
Flag Coverage Δ
partial 0.00% <0.00%> (?)

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: VTOrc Vitess Orchestrator integration Type: Enhancement Logical improvement (somewhere between a bug and feature)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants