Skip to content

vtgate: separate transaction_mode default and limit into independent flags#19426

Open
Devanshusharma2005 wants to merge 4 commits intovitessio:mainfrom
Devanshusharma2005:vtgate-transaction-mode-split
Open

vtgate: separate transaction_mode default and limit into independent flags#19426
Devanshusharma2005 wants to merge 4 commits intovitessio:mainfrom
Devanshusharma2005:vtgate-transaction-mode-split

Conversation

@Devanshusharma2005
Copy link

Description

This PR splits the --transaction-mode flag into three separate flags so operators can independently control the default transaction mode and the maximum mode a session is allowed to SET.
Previously, --transaction-mode did double duty, it set both the default for new sessions and (implicitly) acted as the ceiling.
That made it impossible to say:
“Default to SINGLE for safety, but allow power users to opt into MULTI.”
Now that’s possible.

What changed ?

  1. We now have three flags (all dynamic via viper):
    --transaction-mode (existing) Still works as before. If neither of the new flags are set, both default and limit fall back to this. Fully backward compatible at the flag level.
  2. --transaction-mode-default (new)
    Controls what new sessions start with. Falls back to --transaction-mode if unset.
  3. --transaction-mode-limit (new)
    Defines the ceiling for SET transaction_mode = .... Also falls back to --transaction-mode if unset. If a session tries to set a mode above the limit, we return a MySQL-compatible error.
    Modes have a natural ordering:
    SINGLE < MULTI < TWOPC
    Limit enforcement is simply mode > limit using the enum ordering.
    UNSPECIFIED is always allowed (it just resets to default).
    We also validate at startup that default <= limit. If not, vtgate refuses to start.
    SetTransactionMode now returns an error instead of nothing, which flows through SessionActions and the SET engine.

Related Issue(s)

Fixes #5416

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

I used Claude more like a pairing buddy to brainstorm and generate a wide range of edge cases for the E2E and unit tests, mainly to make sure the limit enforcement holds up against weird or unexpected inputs.
The actual design and implementation especially the Viper flag wiring and session state propagation were done manually. I traced the full SET lifecycle through VTGate using grep and basically did a DFS style walk across the interfaces to make sure transaction_mode flows correctly from SessionActions down to the engine.
Very open to any “tough” edge cases or uncomfortable scenarios the maintainers think I should stress test further

Signed-off-by: Devanshu Sharma <devanshusharma658@gmail.com>
@github-actions github-actions bot added this to the v24.0.0 milestone Feb 19, 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 19, 2026
@vitess-bot
Copy link
Contributor

vitess-bot bot commented Feb 19, 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.

@promptless
Copy link
Contributor

promptless bot commented Feb 19, 2026

📝 Documentation updates detected!

New suggestion: Add changelog entry for VTGate --transaction-mode-default and --transaction-mode-limit flags


Tip: Whenever you leave a comment tagged @Promptless on a Promptless PR, Promptless will remember it for future suggestions 🧠

@promptless
Copy link
Contributor

promptless bot commented Feb 19, 2026

📝 Documentation updates detected!

New suggestion: Document vtgate transaction-mode-default and transaction-mode-limit flags


Tip: Configure how Promptless handles changelogs in Agent Settings 📋

@Devanshusharma2005 Devanshusharma2005 marked this pull request as draft February 19, 2026 08:18
…and vtgombo configuration

Signed-off-by: Devanshu Sharma <devanshusharma658@gmail.com>
@Devanshusharma2005
Copy link
Author

@mhamza15 lets have a look.

…nd backward compatibility checks. Ensure that the absence of the --transaction-mode-limit flag allows unrestricted SET transaction_mode. Update tests to reflect these changes and clarify the behavior of transaction mode limits.

Signed-off-by: Devanshu Sharma <devanshusharma658@gmail.com>
@Devanshusharma2005 Devanshusharma2005 marked this pull request as ready for review February 20, 2026 10:29
@Devanshusharma2005
Copy link
Author

@mhamza15
Think I got the main BC + limit logic covered, but any tricky scenarios worth testing?
Ready to iterate and improve whatever you spot! 🙏

Signed-off-by: Devanshu Sharma <devanshusharma658@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vtgate: Separate transaction_mode default and limit

1 participant