vitess.io/vitess@v0.16.2/go/vt/vttablet/tabletmanager/vreplication/flags.go (about) 1 /* 2 Copyright 2022 The Vitess Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package vreplication 18 19 import ( 20 "time" 21 22 "github.com/spf13/pflag" 23 24 "vitess.io/vitess/go/vt/servenv" 25 ) 26 27 var ( 28 retryDelay = 5 * time.Second 29 maxTimeToRetryError time.Duration // default behavior is to keep retrying, for backward compatibility 30 31 tabletTypesStr = "in_order:REPLICA,PRIMARY" 32 33 relayLogMaxSize = 250000 34 relayLogMaxItems = 5000 35 36 copyPhaseDuration = 1 * time.Hour 37 replicaLagTolerance = 1 * time.Minute 38 39 vreplicationHeartbeatUpdateInterval = 1 40 vreplicationExperimentalFlags = int64(0x01) // enable vreplicationExperimentalFlagOptimizeInserts by default 41 vreplicationStoreCompressedGTID = false 42 vreplicationParallelInsertWorkers = 1 43 ) 44 45 func registerVReplicationFlags(fs *pflag.FlagSet) { 46 fs.DurationVar(&retryDelay, "vreplication_retry_delay", retryDelay, "delay before retrying a failed workflow event in the replication phase") 47 fs.DurationVar(&maxTimeToRetryError, "vreplication_max_time_to_retry_on_error", maxTimeToRetryError, "stop automatically retrying when we've had consecutive failures with the same error for this long after the first occurrence") 48 49 // these are the default tablet_types that will be used by the tablet picker to find source tablets for a vreplication stream 50 // it can be overridden by passing a different list to the MoveTables or Reshard commands 51 fs.StringVar(&tabletTypesStr, "vreplication_tablet_type", tabletTypesStr, "comma separated list of tablet types used as a source") 52 53 fs.IntVar(&relayLogMaxSize, "relay_log_max_size", relayLogMaxSize, "Maximum buffer size (in bytes) for VReplication target buffering. If single rows are larger than this, a single row is buffered at a time.") 54 fs.IntVar(&relayLogMaxItems, "relay_log_max_items", relayLogMaxItems, "Maximum number of rows for VReplication target buffering.") 55 56 fs.DurationVar(©PhaseDuration, "vreplication_copy_phase_duration", copyPhaseDuration, "Duration for each copy phase loop (before running the next catchup: default 1h)") 57 fs.DurationVar(&replicaLagTolerance, "vreplication_replica_lag_tolerance", replicaLagTolerance, "Replica lag threshold duration: once lag is below this we switch from copy phase to the replication (streaming) phase") 58 59 // vreplicationHeartbeatUpdateInterval determines how often the time_updated column is updated if there are no real events on the source and the source 60 // vstream is only sending heartbeats for this long. Keep this low if you expect high QPS and are monitoring this column to alert about potential 61 // outages. Keep this high if 62 // you have too many streams the extra write qps or cpu load due to these updates are unacceptable 63 // you have too many streams and/or a large source field (lot of participating tables) which generates unacceptable increase in your binlog size 64 fs.IntVar(&vreplicationHeartbeatUpdateInterval, "vreplication_heartbeat_update_interval", vreplicationHeartbeatUpdateInterval, "Frequency (in seconds, default 1, max 60) at which the time_updated column of a vreplication stream when idling") 65 fs.Int64Var(&vreplicationExperimentalFlags, "vreplication_experimental_flags", vreplicationExperimentalFlags, "(Bitmask) of experimental features in vreplication to enable") 66 fs.BoolVar(&vreplicationStoreCompressedGTID, "vreplication_store_compressed_gtid", vreplicationStoreCompressedGTID, "Store compressed gtids in the pos column of _vt.vreplication") 67 68 // deprecated flags (7.0), however there are several e2e tests that still depend on them 69 fs.Duration("vreplication_healthcheck_topology_refresh", 30*time.Second, "refresh interval for re-reading the topology") 70 fs.Duration("vreplication_healthcheck_retry_delay", 5*time.Second, "healthcheck retry delay") 71 fs.Duration("vreplication_healthcheck_timeout", 1*time.Minute, "healthcheck retry delay") 72 73 fs.IntVar(&vreplicationParallelInsertWorkers, "vreplication-parallel-insert-workers", vreplicationParallelInsertWorkers, "Number of parallel insertion workers to use during copy phase. Set <= 1 to disable parallelism, or > 1 to enable concurrent insertion during copy phase.") 74 } 75 76 func init() { 77 servenv.OnParseFor("vtcombo", registerVReplicationFlags) 78 servenv.OnParseFor("vttablet", registerVReplicationFlags) 79 }