Skip to content

Conversation

@rjlaine
Copy link
Contributor

@rjlaine rjlaine commented Jan 17, 2026

Description

Add an option to bind ports with SO_REUSEPORT on unix builds of vtgate. SO_REUSEPORT is a unix socket option which allows multiple processes running under the same UID to bind the same port at the same time. The kernel then load balances traffic between all processes listening on the port. This option can be utilized by users who want to update vtgates in place without service interruption, or to hot-reload configuration.

Related Issue(s)

Deployment Notes

No-op unless the new flag is set. The new flag can be used with existing config, without additional configuration changes. However, for users that want to utilize it for hot reload config, additional changes will be required in their specific runtime environment. For a very minimal example, to run hot reloading in a systemd service template, you might set up something like this:

/etc/systemd/system/vtgate@.service

[Unit]
Description=vtgate %i
After=network.target

[Service]
User=vitess
ExecStart=/usr/local/bin/vtgate --mysql_server_port=3306 --reuse-port
ExecStartPost=/bin/sh -c '/bin/systemctl stop vtgate@$(( %i ^1 ))'

And then toggle between the two to hot reload:

i=$(( i ^1 ))
systemctl restart "vtgate@${i}"

Signed-off-by: Riley Laine <rlaine@slack-corp.com>
@github-actions github-actions bot added this to the v24.0.0 milestone Jan 17, 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 Jan 17, 2026
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Jan 17, 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.

@rjlaine rjlaine mentioned this pull request Jan 17, 2026
@promptless
Copy link
Contributor

promptless bot commented Jan 17, 2026

📝 Documentation updates detected!

New suggestion: Add changelog entry for VTGate --reuse-port flag

@promptless
Copy link
Contributor

promptless bot commented Jan 17, 2026

📝 Documentation updates detected!

New suggestion: Document vtgate --reuse-port flag for zero-downtime updates

@mattlord mattlord added Type: Enhancement Logical improvement (somewhere between a bug and feature) Component: Query Serving and removed 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 Jan 20, 2026
@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 56.75676% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.95%. Comparing base (ed22ed7) to head (a65beb0).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtgate/plugin_mysql_server.go 0.00% 7 Missing ⚠️
go/netutil/reuseport_unix.go 76.47% 4 Missing ⚠️
go/vt/servenv/listen.go 62.50% 3 Missing ⚠️
go/mysql/server.go 66.66% 1 Missing ⚠️
go/vt/servenv/run.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19168   +/-   ##
=======================================
  Coverage   69.95%   69.95%           
=======================================
  Files        1610     1612    +2     
  Lines      216083   216112   +29     
=======================================
+ Hits       151159   151190   +31     
+ Misses      64924    64922    -2     

☔ 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.

Signed-off-by: Riley Laine <rlaine@slack-corp.com>
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
@mattlord mattlord removed the NeedsWebsiteDocsUpdate What it says label Jan 21, 2026
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
@rjlaine
Copy link
Contributor Author

rjlaine commented Jan 22, 2026

Is it normal for CI to fail? I merged the latest commits from main, and these 2 tests continue to fail. They don't appear related to my change, but I might be missing something.

@mattlord
Copy link
Member

Is it normal for CI to fail? I merged the latest commits from main, and these 2 tests continue to fail. They don't appear related to my change, but I might be missing something.

You will have to merge in main after this is merged shortly: #19198

Copy link
Contributor

@timvaillancourt timvaillancourt left a comment

Choose a reason for hiding this comment

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

LGTM, just pointed out one linter problem

rjlaine and others added 2 commits January 29, 2026 13:04
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
@timvaillancourt timvaillancourt self-requested a review February 2, 2026 12:51
@demmer demmer enabled auto-merge (squash) February 3, 2026 16:24
@mattlord
Copy link
Member

@rjlaine I apologize for the delay! Can you please merge in origin/main? The new required tests should then run and pass and we can get this merged. ❤️

Signed-off-by: Riley Laine <rlaine@slack-corp.com>
@demmer demmer merged commit a429d18 into vitessio:main Feb 10, 2026
111 of 112 checks passed
@demmer demmer deleted the rlaine-reuseport branch February 10, 2026 19:17
rjlaine added a commit to slackhq/vitess that referenced this pull request Feb 11, 2026
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
rjlaine added a commit to slackhq/vitess that referenced this pull request Feb 11, 2026
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
rjlaine added a commit to slackhq/vitess that referenced this pull request Feb 11, 2026
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
rjlaine added a commit to slackhq/vitess that referenced this pull request Feb 11, 2026
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
rjlaine added a commit to slackhq/vitess that referenced this pull request Feb 11, 2026
Signed-off-by: Riley Laine <rlaine@slack-corp.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Query Serving Type: Enhancement Logical improvement (somewhere between a bug and feature)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: SO_REUSEPORT

5 participants