Skip to content

Commit

Permalink
remove query time hint from tabletmanager
Browse files Browse the repository at this point in the history
Signed-off-by: Olga Shestopalova <oshestopalova@hubspot.com>
  • Loading branch information
Olga Shestopalova committed Oct 11, 2023
1 parent 58fa7d9 commit 9d1e52a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"c1", "pk1", "pk2"},
InsertFront: "insert into t1(c1,c2)",
InsertValues: "(:a_c1,:a_c2)",
Insert: "insert into t1(c1,c2) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, :a_c2 from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert into t1(c1,c2) select :a_c1, :a_c2 from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "update t1 set c2=:a_c2 where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "delete from t1 where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down Expand Up @@ -262,7 +262,7 @@ func TestBuildPlayerPlan(t *testing.T) {
InsertFront: "insert into t1(c1,c2,c3)",
InsertValues: "(:a_c1,:a_c2,:a_c3)",
InsertOnDup: "on duplicate key update c2=values(c2)",
Insert: "insert into t1(c1,c2,c3) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, :a_c2, :a_c3 from dual where (:a_pk1,:a_pk2) <= (1,'aaa') on duplicate key update c2=values(c2)",
Insert: "insert into t1(c1,c2,c3) select :a_c1, :a_c2, :a_c3 from dual where (:a_pk1,:a_pk2) <= (1,'aaa') on duplicate key update c2=values(c2)",
Update: "update t1 set c2=:a_c2 where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "update t1 set c2=null where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down Expand Up @@ -311,8 +311,8 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"c1", "pk1", "pk2"},
InsertFront: "insert ignore into t1(c1,c2,c3)",
InsertValues: "(:a_c1,:a_c2,:a_c3)",
Insert: "insert ignore into t1(c1,c2,c3) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, :a_c2, :a_c3 from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "insert ignore into t1(c1,c2,c3) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, :a_c2, :a_c3 from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert ignore into t1(c1,c2,c3) select :a_c1, :a_c2, :a_c3 from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "insert ignore into t1(c1,c2,c3) select :a_c1, :a_c2, :a_c3 from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
},
},
},
Expand Down Expand Up @@ -359,7 +359,7 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"a", "pk1", "pk2"},
InsertFront: "insert into t1(c1,c2,c3)",
InsertValues: "(foo(:a_a),foo(:a_a, :a_b),:a_c)",
Insert: "insert into t1(c1,c2,c3) select /*+ MAX_EXECUTION_TIME(3600000) */ foo(:a_a), foo(:a_a, :a_b), :a_c from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert into t1(c1,c2,c3) select foo(:a_a), foo(:a_a, :a_b), :a_c from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "update t1 set c2=foo(:a_a, :a_b), c3=:a_c where c1=(foo(:b_a)) and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "delete from t1 where c1=(foo(:b_a)) and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down Expand Up @@ -408,7 +408,7 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"a", "b", "pk1", "pk2"},
InsertFront: "insert into t1(c1,c2)",
InsertValues: "(:a_a + :a_b,:a_c)",
Insert: "insert into t1(c1,c2) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_a + :a_b, :a_c from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert into t1(c1,c2) select :a_a + :a_b, :a_c from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "update t1 set c2=:a_c where c1=(:b_a + :b_b) and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "delete from t1 where c1=(:b_a + :b_b) and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down Expand Up @@ -457,7 +457,7 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"c1", "pk1", "pk2"},
InsertFront: "insert into t1(c1,c2)",
InsertValues: "(:a_c1,convert(:a_c using utf8mb4))",
Insert: "insert into t1(c1,c2) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, convert(:a_c using utf8mb4) from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert into t1(c1,c2) select :a_c1, convert(:a_c using utf8mb4) from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "update t1 set c2=convert(:a_c using utf8mb4) where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "delete from t1 where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down Expand Up @@ -507,7 +507,7 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"c1", "pk1", "pk2"},
InsertFront: "insert into t1(c1,c2,`primary`)",
InsertValues: "(:a_c1,:a_c2,:a_primary)",
Insert: "insert into t1(c1,c2,`primary`) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, :a_c2, :a_primary from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert into t1(c1,c2,`primary`) select :a_c1, :a_c2, :a_primary from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "update t1 set c2=:a_c2, `primary`=:a_primary where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "delete from t1 where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down Expand Up @@ -557,7 +557,7 @@ func TestBuildPlayerPlan(t *testing.T) {
PKReferences: []string{"c1", "pk1", "pk2"},
InsertFront: "insert into t1(c1,c2,ksid)",
InsertValues: "(:a_c1,:a_c2,:a_keyspace_id)",
Insert: "insert into t1(c1,c2,ksid) select /*+ MAX_EXECUTION_TIME(3600000) */ :a_c1, :a_c2, :a_keyspace_id from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Insert: "insert into t1(c1,c2,ksid) select :a_c1, :a_c2, :a_keyspace_id from dual where (:a_pk1,:a_pk2) <= (1,'aaa')",
Update: "update t1 set c2=:a_c2, ksid=:a_keyspace_id where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
Delete: "delete from t1 where c1=:b_c1 and (:b_pk1,:b_pk2) <= (1,'aaa')",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
querypb "vitess.io/vitess/go/vt/proto/query"
"vitess.io/vitess/go/vt/schema"
"vitess.io/vitess/go/vt/sqlparser"
"vitess.io/vitess/go/vt/vttablet/tabletserver/vstreamer"
)

// This file contains just the builders for ReplicatorPlan and TablePlan.
Expand Down Expand Up @@ -727,7 +726,6 @@ func (tpb *tablePlanBuilder) generateValuesPart(buf *sqlparser.TrackedBuffer, bv
func (tpb *tablePlanBuilder) generateSelectPart(buf *sqlparser.TrackedBuffer, bvf *bindvarFormatter) *sqlparser.ParsedQuery {
bvf.mode = bvAfter
buf.WriteString(" select ")
buf.WriteString(vstreamer.GetVReplicationMaxExecutionTimeQueryHint())
separator := ""
for _, cexpr := range tpb.colExprs {
if tpb.isColumnGenerated(cexpr.colName) {
Expand Down
20 changes: 10 additions & 10 deletions go/vt/vttablet/tabletmanager/vreplication/vcopier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func testPlayerCopyVarcharPKCaseInsensitive(t *testing.T) {
"insert into dst(idc,val) values ('a',1)",
`/insert into _vt.copy_state \(lastpk, vrepl_id, table_name\) values \('fields:{name:\\"idc\\" type:VARCHAR charset:45 flags:20483} rows:{lengths:1 values:\\"a\\"}'.*`,
// Copy-catchup mode.
`/insert into dst\(idc,val\) select /\*\+ MAX_EXECUTION_TIME\(500\) \*/ 'B', 3 from dual where \( .* 'B' COLLATE .* \) <= \( .* 'a' COLLATE .* \)`,
`/insert into dst\(idc,val\) select 'B', 3 from dual where \( .* 'B' COLLATE .* \) <= \( .* 'a' COLLATE .* \)`,
).Then(func(expect qh.ExpectationSequencer) qh.ExpectationSequencer {
// Back to copy mode.
// Inserts can happen out of order.
Expand Down Expand Up @@ -409,7 +409,7 @@ func testPlayerCopyVarcharCompositePKCaseSensitiveCollation(t *testing.T) {
"insert into dst(id,idc,idc2,val) values (1,'a','a',1)",
`/insert into _vt.copy_state \(lastpk, vrepl_id, table_name\) values \('fields:{name:\\"id\\" type:INT32 charset:63 flags:53251} fields:{name:\\"idc\\" type:VARBINARY charset:63 flags:20611} fields:{name:\\"idc2\\" type:VARBINARY charset:63 flags:20611} rows:{lengths:1 lengths:1 lengths:1 values:\\"1aa\\"}'.*`,
// Copy-catchup mode.
`insert into dst(id,idc,idc2,val) select /*+ MAX_EXECUTION_TIME(500) */ 1, 'B', 'B', 3 from dual where (1,'B','B') <= (1,'a','a')`,
`insert into dst(id,idc,idc2,val) select 1, 'B', 'B', 3 from dual where (1,'B','B') <= (1,'a','a')`,
// Copy mode.
"insert into dst(id,idc,idc2,val) values (1,'c','c',2)",
`/insert into _vt.copy_state \(lastpk, vrepl_id, table_name\) values \('fields:{name:\\"id\\" type:INT32 charset:63 flags:53251} fields:{name:\\"idc\\" type:VARBINARY charset:63 flags:20611} fields:{name:\\"idc2\\" type:VARBINARY charset:63 flags:20611} rows:{lengths:1 lengths:1 lengths:1 values:\\"1cc\\"}'.*`,
Expand Down Expand Up @@ -757,7 +757,7 @@ func testPlayerCopyBigTable(t *testing.T) {
"insert into dst(id,val) values (1,'aaa')",
`/insert into _vt.copy_state \(lastpk, vrepl_id, table_name\) values \('fields:{name:\\"id\\" type:INT32 charset:63 flags:53251} rows:{lengths:1 values:\\"1\\"}'.*`,
// The next catchup executes the new row insert, but will be a no-op.
"insert into dst(id,val) select /*+ MAX_EXECUTION_TIME(500) */ 3, 'ccc' from dual where (3) <= (1)",
"insert into dst(id,val) select 3, 'ccc' from dual where (3) <= (1)",
// fastForward has nothing to add. Just saves position.
// Back to copy mode.
// Inserts can happen out-of-order.
Expand Down Expand Up @@ -887,7 +887,7 @@ func testPlayerCopyWildcardRule(t *testing.T) {
"insert into src(id,val) values (1,'aaa')",
`/insert into _vt.copy_state \(lastpk, vrepl_id, table_name\) values \('fields:{name:\\"id\\" type:INT32 charset:63 flags:53251} rows:{lengths:1 values:\\"1\\"}'.*`,
// The next catchup executes the new row insert, but will be a no-op.
"insert into src(id,val) select /*+ MAX_EXECUTION_TIME(500) */ 3, 'ccc' from dual where (3) <= (1)",
"insert into src(id,val) select 3, 'ccc' from dual where (3) <= (1)",
// fastForward has nothing to add. Just saves position.
// Return to copy mode.
// Inserts can happen out-of-order.
Expand Down Expand Up @@ -1042,18 +1042,18 @@ func testPlayerCopyTableContinuation(t *testing.T) {
expectNontxQueries(t, qh.Expect(
// Catchup
"/update _vt.vreplication set message='Picked source tablet.*",
"insert into dst1(id,val) select /*+ MAX_EXECUTION_TIME(3600000) */ 1, 'insert in' from dual where (1,1) <= (6,6)",
"insert into dst1(id,val) select /*+ MAX_EXECUTION_TIME(3600000) */ 7, 'insert out' from dual where (7,7) <= (6,6)",
"insert into dst1(id,val) select 1, 'insert in' from dual where (1,1) <= (6,6)",
"insert into dst1(id,val) select 7, 'insert out' from dual where (7,7) <= (6,6)",
"update dst1 set val='updated' where id=3 and (3,3) <= (6,6)",
"update dst1 set val='updated' where id=10 and (10,10) <= (6,6)",
"delete from dst1 where id=4 and (4,4) <= (6,6)",
"delete from dst1 where id=9 and (9,9) <= (6,6)",
"delete from dst1 where id=5 and (5,5) <= (6,6)",
"insert into dst1(id,val) select /*+ MAX_EXECUTION_TIME(3600000) */ 5, 'move within' from dual where (5,10) <= (6,6)",
"insert into dst1(id,val) select 5, 'move within' from dual where (5,10) <= (6,6)",
"delete from dst1 where id=6 and (6,6) <= (6,6)",
"insert into dst1(id,val) select /*+ MAX_EXECUTION_TIME(3600000) */ 12, 'move out' from dual where (12,6) <= (6,6)",
"insert into dst1(id,val) select 12, 'move out' from dual where (12,6) <= (6,6)",
"delete from dst1 where id=11 and (11,11) <= (6,6)",
"insert into dst1(id,val) select /*+ MAX_EXECUTION_TIME(3600000) */ 4, 'move in' from dual where (4,11) <= (6,6)",
"insert into dst1(id,val) select 4, 'move in' from dual where (4,11) <= (6,6)",
"update copied set val='bbb' where id=1",
// Fast-forward
"update dst1 set val='updated again' where id=3 and (3,3) <= (6,6)",
Expand Down Expand Up @@ -1174,7 +1174,7 @@ func testPlayerCopyWildcardTableContinuation(t *testing.T) {
"/update _vt.vreplication set message='Picked source tablet.*",
).Then(func(expect qh.ExpectationSequencer) qh.ExpectationSequencer {
if !optimizeInsertsEnabled {
expect = expect.Then(qh.Immediately("insert into dst(id,val) select /*+ MAX_EXECUTION_TIME(3600000) */ 4, 'new' from dual where (4) <= (2)"))
expect = expect.Then(qh.Immediately("insert into dst(id,val) select 4, 'new' from dual where (4) <= (2)"))
}
return expect.Then(qh.Immediately("insert into dst(id,val) values (3,'uncopied'), (4,'new')"))
}).Then(qh.Immediately(
Expand Down

0 comments on commit 9d1e52a

Please sign in to comment.