Skip to content

Commit 84ea974

Browse files
authored
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
2 parents e1151b9 + 71d548c commit 84ea974

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

go/flags/endtoend/vttablet.txt

+2
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ Usage of vttablet:
356356
--vreplication_healthcheck_topology_refresh duration refresh interval for re-reading the topology (default 30s)
357357
--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)
358358
--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
359+
--vreplication_net_read_timeout int Session value of net_read_timeout for vreplication, in seconds (default 300)
360+
--vreplication_net_write_timeout int Session value of net_write_timeout for vreplication, in seconds (default 600)
359361
--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)
360362
--vreplication_retry_delay duration delay before retrying a failed workflow event in the replication phase (default 5s)
361363
--vreplication_store_compressed_gtid Store compressed gtids in the pos column of _vt.vreplication

go/vt/vttablet/flags.go

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright 2023 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 vttablet
18+
19+
import (
20+
"github.com/spf13/pflag"
21+
22+
"vitess.io/vitess/go/vt/servenv"
23+
)
24+
25+
var (
26+
VReplicationNetReadTimeout = 300
27+
VReplicationNetWriteTimeout = 600
28+
)
29+
30+
func init() {
31+
servenv.OnParseFor("vttablet", registerFlags)
32+
}
33+
34+
func registerFlags(fs *pflag.FlagSet) {
35+
fs.IntVar(&VReplicationNetReadTimeout, "vreplication_net_read_timeout", VReplicationNetReadTimeout, "Session value of net_read_timeout for vreplication, in seconds")
36+
fs.IntVar(&VReplicationNetWriteTimeout, "vreplication_net_write_timeout", VReplicationNetWriteTimeout, "Session value of net_write_timeout for vreplication, in seconds")
37+
}

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

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

25+
"vitess.io/vitess/go/vt/vttablet"
26+
2527
"google.golang.org/protobuf/encoding/prototext"
2628

2729
"vitess.io/vitess/go/vt/discovery"
@@ -245,6 +247,12 @@ func (ct *controller) runBlp(ctx context.Context) (err error) {
245247
if _, err := dbClient.ExecuteFetch("set names binary", 10000); err != nil {
246248
return err
247249
}
250+
if _, err := dbClient.ExecuteFetch(fmt.Sprintf("set @@session.net_read_timeout = %v", vttablet.VReplicationNetReadTimeout), 10000); err != nil {
251+
return err
252+
}
253+
if _, err := dbClient.ExecuteFetch(fmt.Sprintf("set @@session.net_write_timeout = %v", vttablet.VReplicationNetWriteTimeout), 10000); err != nil {
254+
return err
255+
}
248256
// 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.
249257
if _, err := dbClient.ExecuteFetch("set @@session.sql_mode = CONCAT(@@session.sql_mode, ',NO_AUTO_VALUE_ON_ZERO')", 10000); err != nil {
250258
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"
@@ -122,6 +124,12 @@ func (rs *rowStreamer) Stream() error {
122124
if _, err := conn.ExecuteFetch("set names binary", 1, false); err != nil {
123125
return err
124126
}
127+
if _, err := conn.ExecuteFetch(fmt.Sprintf("set @@session.net_read_timeout = %v", vttablet.VReplicationNetReadTimeout), 1, false); err != nil {
128+
return err
129+
}
130+
if _, err := conn.ExecuteFetch(fmt.Sprintf("set @@session.net_write_timeout = %v", vttablet.VReplicationNetWriteTimeout), 1, false); err != nil {
131+
return err
132+
}
125133
return rs.streamQuery(conn, rs.send)
126134
}
127135

0 commit comments

Comments
 (0)