Skip to content

Commit

Permalink
Merge branch 'slack-19.0' into fix-structured-logging_slack-19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
timvaillancourt authored Oct 16, 2024
2 parents 284528e + 987e2a6 commit 9b1d15f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ Flags:
--tx_throttler_config string The configuration of the transaction throttler as a text-formatted throttlerdata.Configuration protocol buffer message. (default "target_replication_lag_sec:2 max_replication_lag_sec:10 initial_rate:100 max_increase:1 emergency_decrease:0.5 min_duration_between_increases_sec:40 max_duration_between_increases_sec:62 min_duration_between_decreases_sec:20 spread_backlog_across_sec:20 age_bad_rate_after_sec:180 bad_rate_increase:0.1 max_rate_approach_threshold:0.9")
--tx_throttler_healthcheck_cells strings A comma-separated list of cells. Only tabletservers running in these cells will be monitored for replication lag by the transaction throttler.
--unhealthy_threshold duration replication lag after which a replica is considered unhealthy (default 2h0m0s)
--use_super_read_only Set super_read_only flag when performing planned failover.
--v Level log level for V logs
-v, --version print binary version
--vmodule vModuleFlag comma-separated list of pattern=N settings for file-filtered logging
Expand Down
27 changes: 23 additions & 4 deletions go/vt/vttablet/tabletmanager/rpc_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"strings"
"time"

"github.com/spf13/pflag"

"vitess.io/vitess/go/mysql/replication"
"vitess.io/vitess/go/mysql/sqlerror"
"vitess.io/vitess/go/protoutil"
Expand All @@ -30,13 +32,24 @@ import (
"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/mysqlctl"
"vitess.io/vitess/go/vt/proto/vtrpc"
"vitess.io/vitess/go/vt/servenv"
"vitess.io/vitess/go/vt/topo/topoproto"
"vitess.io/vitess/go/vt/vterrors"

replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata"
topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

var setSuperReadOnly bool

func registerReplicationFlags(fs *pflag.FlagSet) {
fs.BoolVar(&setSuperReadOnly, "use_super_read_only", setSuperReadOnly, "Set super_read_only flag when performing planned failover.")
}

func init() {
servenv.OnParseFor("vttablet", registerReplicationFlags)
}

// ReplicationStatus returns the replication status
func (tm *TabletManager) ReplicationStatus(ctx context.Context) (*replicationdatapb.Status, error) {
if err := tm.waitForGrantsToHaveApplied(ctx); err != nil {
Expand Down Expand Up @@ -528,10 +541,16 @@ func (tm *TabletManager) demotePrimary(ctx context.Context, revertPartialFailure
// set MySQL to super_read_only mode. If we are already super_read_only because of a
// previous demotion, or because we are not primary anyway, this should be
// idempotent.
if _, err := tm.MysqlDaemon.SetSuperReadOnly(true); err != nil {
if sqlErr, ok := err.(*sqlerror.SQLError); ok && sqlErr.Number() == sqlerror.ERUnknownSystemVariable {
log.Warningf("server does not know about super_read_only, continuing anyway...")
} else {
if setSuperReadOnly {
if _, err := tm.MysqlDaemon.SetSuperReadOnly(true); err != nil {
if sqlErr, ok := err.(*sqlerror.SQLError); ok && sqlErr.Number() == sqlerror.ERUnknownSystemVariable {
log.Warningf("server does not know about super_read_only, continuing anyway...")
} else {
return nil, err
}
}
} else {
if err := tm.MysqlDaemon.SetReadOnly(true); err != nil {
return nil, err
}
}
Expand Down

0 comments on commit 9b1d15f

Please sign in to comment.