Skip to content

Commit 00c7c2d

Browse files
committed
vttablet: deprecate StrictMode in favor of RBR
StrictMode was an old flag and pretty much unsafe to turn off. It's now been removed. Instead, if we detect that we're in RBR mode, we use that to just pass-through queries that are otherwise too complex.
1 parent d2b83d0 commit 00c7c2d

File tree

9 files changed

+48
-155
lines changed

9 files changed

+48
-155
lines changed

go/vt/vttablet/endtoend/config_test.go

+1-55
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
"time"
1313

1414
vtrpcpb "github.com/youtube/vitess/go/vt/proto/vtrpc"
15+
"github.com/youtube/vitess/go/vt/vterrors"
1516
"github.com/youtube/vitess/go/vt/vttablet/endtoend/framework"
1617
"github.com/youtube/vitess/go/vt/vttablet/tabletserver/tabletenv"
17-
"github.com/youtube/vitess/go/vt/vterrors"
1818
)
1919

2020
// compareIntDiff returns an error if end[tag] != start[tag]+diff.
@@ -328,57 +328,3 @@ func TestQueryTimeout(t *testing.T) {
328328
t.Error(err)
329329
}
330330
}
331-
332-
func TestStrictMode(t *testing.T) {
333-
queries := []string{
334-
"insert into vitess_a(eid, id, name, foo) values (7, 1+1, '', '')",
335-
"insert into vitess_d(eid, id) values (1, 1)",
336-
"update vitess_a set eid = 1+1 where eid = 1 and id = 1",
337-
"insert into vitess_d(eid, id) values (1, 1)",
338-
"insert into upsert_test(id1, id2) values " +
339-
"(1, 1), (2, 2) on duplicate key update id1 = 1",
340-
"insert into upsert_test(id1, id2) select eid, id " +
341-
"from vitess_a limit 1 on duplicate key update id2 = id1",
342-
"insert into upsert_test(id1, id2) values " +
343-
"(1, 1) on duplicate key update id1 = 2+1",
344-
}
345-
346-
// Strict mode on.
347-
func() {
348-
client := framework.NewClient()
349-
err := client.Begin()
350-
if err != nil {
351-
t.Error(err)
352-
return
353-
}
354-
defer client.Rollback()
355-
356-
want := "DML too complex"
357-
for _, query := range queries {
358-
_, err = client.Execute(query, nil)
359-
if err == nil || err.Error() != want {
360-
t.Errorf("Execute(%s): %v, want %s", query, err, want)
361-
}
362-
}
363-
}()
364-
365-
// Strict mode off.
366-
func() {
367-
framework.Server.SetStrictMode(false)
368-
defer framework.Server.SetStrictMode(true)
369-
370-
for _, query := range queries {
371-
client := framework.NewClient()
372-
err := client.Begin()
373-
if err != nil {
374-
t.Error(err)
375-
return
376-
}
377-
_, err = client.Execute(query, nil)
378-
if err != nil {
379-
t.Error(err)
380-
}
381-
client.Rollback()
382-
}
383-
}()
384-
}

go/vt/vttablet/tabletserver/query_engine.go

-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ type QueryEngine struct {
120120
streamQList *QueryList
121121

122122
// Vars
123-
strictMode sync2.AtomicBool
124123
binlogFormat connpool.BinlogFormat
125124
autoCommit sync2.AtomicBool
126125
maxResultSize sync2.AtomicInt64
@@ -171,7 +170,6 @@ func NewQueryEngine(checker connpool.MySQLChecker, se *schema.Engine, config tab
171170
config.HotRowProtectionMaxQueueSize, config.HotRowProtectionMaxGlobalQueueSize)
172171
qe.streamQList = NewQueryList()
173172

174-
qe.strictMode.Set(config.StrictMode)
175173
qe.autoCommit.Set(config.EnableAutoCommit)
176174
qe.strictTableACL = config.StrictTableACL
177175
qe.enableTableACLDryRun = config.EnableTableACLDryRun

go/vt/vttablet/tabletserver/query_engine_test.go

-21
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,6 @@ import (
2020
"github.com/youtube/vitess/go/vt/vttablet/tabletserver/tabletenv"
2121
)
2222

23-
func TestStrictMode(t *testing.T) {
24-
db := fakesqldb.New(t)
25-
defer db.Close()
26-
for query, result := range schematest.Queries() {
27-
db.AddQuery(query, result)
28-
}
29-
db.AddRejectedQuery("select @@global.sql_mode", errRejected)
30-
31-
qe := newTestQueryEngine(10, 10*time.Second, true)
32-
testUtils := newTestUtils()
33-
dbconfigs := testUtils.newDBConfigs(db)
34-
qe.se.Open(db.ConnParams())
35-
36-
err := qe.Open(dbconfigs)
37-
want := "could not verify mode"
38-
if err == nil || !strings.Contains(err.Error(), want) {
39-
t.Errorf("se.Open: %v, must contain %s", err, want)
40-
}
41-
}
42-
4323
func TestGetPlanPanicDuetoEmptyQuery(t *testing.T) {
4424
db := fakesqldb.New(t)
4525
defer db.Close()
@@ -144,6 +124,5 @@ func newTestQueryEngine(queryCacheSize int, idleTimeout time.Duration, strict bo
144124
config := tabletenv.DefaultQsConfig
145125
config.QueryCacheSize = queryCacheSize
146126
config.IdleTimeout = float64(idleTimeout) / 1e9
147-
config.StrictMode = strict
148127
return NewQueryEngine(DummyChecker, schema.NewEngine(DummyChecker, config), config)
149128
}

go/vt/vttablet/tabletserver/query_executor.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (qre *QueryExecutor) Execute() (reply *sqltypes.Result, err error) {
9090
defer conn.Recycle()
9191
switch qre.plan.PlanID {
9292
case planbuilder.PlanPassDML:
93-
if qre.tsv.qe.strictMode.Get() {
93+
if qre.tsv.qe.binlogFormat != connpool.BinlogFormatRow {
9494
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "DML too complex")
9595
}
9696
return qre.txFetch(conn, qre.plan.FullQuery, qre.bindVars, nil, false, true)
@@ -168,7 +168,7 @@ func (qre *QueryExecutor) execDmlAutoCommit() (reply *sqltypes.Result, err error
168168
return qre.execAsTransaction(func(conn *TxConnection) (reply *sqltypes.Result, err error) {
169169
switch qre.plan.PlanID {
170170
case planbuilder.PlanPassDML:
171-
if qre.tsv.qe.strictMode.Get() {
171+
if qre.tsv.qe.binlogFormat != connpool.BinlogFormatRow {
172172
return nil, vterrors.Errorf(vtrpcpb.Code_INVALID_ARGUMENT, "DML too complex")
173173
}
174174
reply, err = qre.txFetch(conn, qre.plan.FullQuery, qre.bindVars, nil, false, true)

0 commit comments

Comments
 (0)