Skip to content

Comments

Restore super_read_only to initial state after SetReplicationSource#801

Draft
tanjinx wants to merge 1 commit intoslack-22.0from
disable-sro-after-demotion
Draft

Restore super_read_only to initial state after SetReplicationSource#801
tanjinx wants to merge 1 commit intoslack-22.0from
disable-sro-after-demotion

Conversation

@tanjinx
Copy link

@tanjinx tanjinx commented Feb 20, 2026

After a PRIMARY is demoted, DemotePrimary sets super_read_only=ON for safety during the critical demotion phase. However, normal replicas don't have super_read_only enabled by default (unless explicitly configured in my.cnf).

This change captures the initial super_read_only state at tablet startup (reflecting the my.cnf configuration) and restores it after SetReplicationSource completes. This ensures demoted primaries behave consistently with other replicas in the shard.

Files Changed:

  1. go/vt/vttablet/tabletmanager/tm_init.go
    - Added disableSuperReadOnly flag variable (default false)
    - Registered --disable_super_read_only flag
  2. go/vt/vttablet/tabletmanager/rpc_replication.go
    - Added logic to turn off super_read_only after demotion when flag is enabled
    - Only applies when wasPrimary && disableSuperReadOnly
  3. go/flags/endtoend/vttablet.txt
    - Added documentation for --disable_super_read_only flag
  4. go/flags/endtoend/vtcombo.txt
    - Added documentation for --disable_super_read_only flag

Behavior:

Default (--disable_super_read_only=false):

  • After PRIMARY demotion, super_read_only remains ON
  • Provides extra protection against accidental writes
  • Demoted primary has different state than normal replicas

Enabled (--disable_super_read_only=true):

  • After PRIMARY demotion, super_read_only is turned OFF
  • Demoted primary matches normal replica behavior
  • Consistent with default MySQL configuration

The safety benefit of super_read_only=ON during the critical demotion phase is preserved in
both cases.

Description

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

@github-actions github-actions bot added this to the v22.0.3 milestone Feb 20, 2026
@tanjinx tanjinx force-pushed the disable-sro-after-demotion branch from ae635de to c46d898 Compare February 20, 2026 23:10
…demotion

After a PRIMARY is demoted, DemotePrimary sets super_read_only=ON for safety during the critical demotion phase. However, normal replicas don't have super_read_only enabled by default.

This change adds a vttablet configuration flag --disable_super_read_only (default false) that controls whether to turn off super_read_only in SetReplicationSource after replication is established.

When --disable_super_read_only=false (default): super_read_only remains enabled after demotion, providing extra protection.

When --disable_super_read_only=true: super_read_only is turned off to match normal replica behavior.

The safety benefit of super_read_only=ON during the demotion phase is preserved in both cases.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Signed-off-by: Tanjin Xu <tanjin.xu@slack-corp.com>
@tanjinx tanjinx force-pushed the disable-sro-after-demotion branch from c46d898 to 2b9df49 Compare February 20, 2026 23:21
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 10.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.78%. Comparing base (b1ab347) to head (2b9df49).
⚠️ Report is 32 commits behind head on slack-22.0.

Files with missing lines Patch % Lines
go/vt/vttablet/tabletmanager/rpc_replication.go 0.00% 9 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           slack-22.0     #801      +/-   ##
==============================================
+ Coverage       67.53%   69.78%   +2.25%     
==============================================
  Files            1600     1605       +5     
  Lines          261782   214036   -47746     
==============================================
- Hits           176786   149374   -27412     
+ Misses          84996    64662   -20334     

☔ 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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants