Skip to content

Commit dde1210

Browse files
pawandubeyshivnagarajan
authored andcommitted
Merge pull request #155 from Shopify/candidate-v15.0.3-shopify-11
Backport: set vreplication net read and net write timeout session vars to high values (cherry picked from commit 84ea974) (cherry picked from commit 5cc2dfc)
1 parent fdefd71 commit dde1210

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

go/flags/endtoend/vttablet.txt

+2
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ Usage of vttablet:
376376
--vreplication_healthcheck_topology_refresh duration refresh interval for re-reading the topology (default 30s)
377377
--vreplication_heartbeat_update_interval int Frequency (in seconds, default 1, max 60) at which the time_updated column of a vreplication stream when idling (default 1)
378378
--vreplication_max_time_to_retry_on_error duration stop automatically retrying when we've had consecutive failures with the same error for this long after the first occurrence
379+
--vreplication_net_read_timeout int Session value of net_read_timeout for vreplication, in seconds (default 300)
380+
--vreplication_net_write_timeout int Session value of net_write_timeout for vreplication, in seconds (default 600)
379381
--vreplication_replica_lag_tolerance duration Replica lag threshold duration: once lag is below this we switch from copy phase to the replication (streaming) phase (default 1m0s)
380382
--vreplication_retry_delay duration delay before retrying a failed workflow event in the replication phase (default 5s)
381383
--vreplication_store_compressed_gtid Store compressed gtids in the pos column of the sidecar database's vreplication table

go/vt/vttablet/flags.go

+7
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,18 @@ const (
2929

3030
var VReplicationExperimentalFlags = VReplicationExperimentalFlagOptimizeInserts | VReplicationExperimentalFlagAllowNoBlobBinlogRowImage
3131

32+
var (
33+
VReplicationNetReadTimeout = 300
34+
VReplicationNetWriteTimeout = 600
35+
)
36+
3237
func init() {
3338
servenv.OnParseFor("vttablet", registerFlags)
3439
}
3540

3641
func registerFlags(fs *pflag.FlagSet) {
3742
fs.Int64Var(&VReplicationExperimentalFlags, "vreplication_experimental_flags", VReplicationExperimentalFlags,
3843
"(Bitmask) of experimental features in vreplication to enable")
44+
fs.IntVar(&VReplicationNetReadTimeout, "vreplication_net_read_timeout", VReplicationNetReadTimeout, "Session value of net_read_timeout for vreplication, in seconds")
45+
fs.IntVar(&VReplicationNetWriteTimeout, "vreplication_net_write_timeout", VReplicationNetWriteTimeout, "Session value of net_write_timeout for vreplication, in seconds")
3946
}

go/vt/vttablet/tabletmanager/vreplication/controller.go

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import (
2424
"sync/atomic"
2525
"time"
2626

27+
"vitess.io/vitess/go/vt/vttablet"
28+
2729
"google.golang.org/protobuf/encoding/prototext"
2830

2931
"vitess.io/vitess/go/vt/discovery"
@@ -243,6 +245,12 @@ func (ct *controller) runBlp(ctx context.Context) (err error) {
243245
if _, err := dbClient.ExecuteFetch("set names 'binary'", 10000); err != nil {
244246
return err
245247
}
248+
if _, err := dbClient.ExecuteFetch(fmt.Sprintf("set @@session.net_read_timeout = %v", vttablet.VReplicationNetReadTimeout), 10000); err != nil {
249+
return err
250+
}
251+
if _, err := dbClient.ExecuteFetch(fmt.Sprintf("set @@session.net_write_timeout = %v", vttablet.VReplicationNetWriteTimeout), 10000); err != nil {
252+
return err
253+
}
246254
// We must apply AUTO_INCREMENT values precisely as we got them. This include the 0 value, which is not recommended in AUTO_INCREMENT, and yet is valid.
247255
if _, err := dbClient.ExecuteFetch("set @@session.sql_mode = CONCAT(@@session.sql_mode, ',NO_AUTO_VALUE_ON_ZERO')", 10000); err != nil {
248256
return err

go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go

+8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"time"
2424

2525
"vitess.io/vitess/go/mysql"
26+
"vitess.io/vitess/go/vt/vttablet"
27+
2628
"vitess.io/vitess/go/mysql/collations"
2729
"vitess.io/vitess/go/sqltypes"
2830
"vitess.io/vitess/go/textutil"
@@ -119,6 +121,12 @@ func (rs *rowStreamer) Stream() error {
119121
if _, err := conn.ExecuteFetch("set names 'binary'", 1, false); err != nil {
120122
return err
121123
}
124+
if _, err := conn.ExecuteFetch(fmt.Sprintf("set @@session.net_read_timeout = %v", vttablet.VReplicationNetReadTimeout), 1, false); err != nil {
125+
return err
126+
}
127+
if _, err := conn.ExecuteFetch(fmt.Sprintf("set @@session.net_write_timeout = %v", vttablet.VReplicationNetWriteTimeout), 1, false); err != nil {
128+
return err
129+
}
122130
return rs.streamQuery(conn, rs.send)
123131
}
124132

0 commit comments

Comments
 (0)