Skip to content

Commit c67bb6f

Browse files
resolve conflicts for backport of #19674
Signed-off-by: Tim Vaillancourt <tim@timvaillancourt.com>
1 parent c5dc965 commit c67bb6f

3 files changed

Lines changed: 14 additions & 54 deletions

File tree

go/vt/vtgate/engine/route.go

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,10 @@ import (
4141

4242
var _ Primitive = (*Route)(nil)
4343

44-
var (
45-
replicaWarmingReadsMirrored = stats.NewCountersWithMultiLabels(
46-
"ReplicaWarmingReadsMirrored",
47-
"Number of reads mirrored to replicas to warm their bufferpools",
48-
[]string{"Keyspace"})
49-
)
44+
var replicaWarmingReadsMirrored = stats.NewCountersWithMultiLabels(
45+
"ReplicaWarmingReadsMirrored",
46+
"Number of reads mirrored to replicas to warm their bufferpools",
47+
[]string{"Keyspace"})
5048

5149
// Route represents the instructions to route a read query to
5250
// one or many vttablets.
@@ -103,9 +101,7 @@ func NewRoute(opcode Opcode, keyspace *vindexes.Keyspace, query, fieldQuery stri
103101
}
104102
}
105103

106-
var (
107-
partialSuccessScatterQueries = stats.NewCounter("PartialSuccessScatterQueries", "Count of partially successful scatter queries")
108-
)
104+
var partialSuccessScatterQueries = stats.NewCounter("PartialSuccessScatterQueries", "Count of partially successful scatter queries")
109105

110106
// TryExecute performs a non-streaming exec.
111107
func (route *Route) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) {
@@ -512,22 +508,6 @@ func (route *Route) executeWarmingReplicaRead(ctx context.Context, vcursor VCurs
512508
return
513509
}
514510

515-
<<<<<<< HEAD
516-
replicaVCursor := vcursor.CloneForReplicaWarming(ctx)
517-
=======
518-
// Remove FOR UPDATE locks for warming reads if present
519-
warmingQueries := queries
520-
if modifiedQuery, ok := removeForUpdateLocks(route.QueryStatement); ok {
521-
warmingQueries = make([]*querypb.BoundQuery, len(queries))
522-
for i, query := range queries {
523-
warmingQueries[i] = &querypb.BoundQuery{
524-
Sql: modifiedQuery,
525-
BindVariables: query.BindVariables,
526-
}
527-
}
528-
}
529-
530-
>>>>>>> 8c937df416 (VTGate: fix warming reads timeout context (#19674))
531511
warmingReadsChannel := vcursor.GetWarmingReadsChannel()
532512

533513
select {
@@ -546,11 +526,7 @@ func (route *Route) executeWarmingReplicaRead(ctx context.Context, vcursor VCurs
546526
return
547527
}
548528

549-
<<<<<<< HEAD
550-
_, errs := replicaVCursor.ExecuteMultiShard(ctx, route, rss, queries, false /*rollbackOnError*/, false /*canAutocommit*/, route.FetchLastInsertID)
551-
=======
552-
_, errs := replicaVCursor.ExecuteMultiShard(warmingCtx, route, rss, warmingQueries, false /*rollbackOnError*/, false /*canAutocommit*/, route.FetchLastInsertID)
553-
>>>>>>> 8c937df416 (VTGate: fix warming reads timeout context (#19674))
529+
_, errs := replicaVCursor.ExecuteMultiShard(warmingCtx, route, rss, queries, false /*rollbackOnError*/, false /*canAutocommit*/, route.FetchLastInsertID)
554530
if len(errs) > 0 {
555531
log.Warningf("Failed to execute warming replica read: %v", errs)
556532
} else {

go/vt/vtgate/engine/route_warming_reads_test.go

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/stretchr/testify/require"
2626

2727
"vitess.io/vitess/go/sqltypes"
28-
"vitess.io/vitess/go/vt/sqlparser"
2928
"vitess.io/vitess/go/vt/srvtopo"
3029
"vitess.io/vitess/go/vt/vtgate/evalengine"
3130
"vitess.io/vitess/go/vt/vtgate/vindexes"
@@ -80,37 +79,37 @@ func TestWarmingReadsSkipsForUpdate(t *testing.T) {
8079
{
8180
name: "SELECT FOR UPDATE",
8281
query: "SELECT * FROM users WHERE id = 1 FOR UPDATE",
83-
expectedWarmingQuery: "select * from users where id = 1",
82+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 FOR UPDATE",
8483
},
8584
{
8685
name: "SELECT FOR UPDATE mixed case",
8786
query: "SELECT * FROM users WHERE id = 1 FoR UpDaTe",
88-
expectedWarmingQuery: "select * from users where id = 1",
87+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 FoR UpDaTe",
8988
},
9089
{
9190
name: "SELECT FOR UPDATE with extra spaces",
9291
query: "SELECT * FROM users WHERE id = 1 FOR UPDATE",
93-
expectedWarmingQuery: "select * from users where id = 1",
92+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 FOR UPDATE",
9493
},
9594
{
9695
name: "SELECT FOR UPDATE with comment",
9796
query: "SELECT * FROM users WHERE id = 1 FOR /* comment */ UPDATE",
98-
expectedWarmingQuery: "select * from users where id = 1",
97+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 FOR /* comment */ UPDATE",
9998
},
10099
{
101100
name: "SELECT FOR UPDATE NOWAIT",
102101
query: "SELECT * FROM users WHERE id = 1 FOR UPDATE NOWAIT",
103-
expectedWarmingQuery: "select * from users where id = 1",
102+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 FOR UPDATE NOWAIT",
104103
},
105104
{
106105
name: "SELECT FOR UPDATE SKIP LOCKED",
107106
query: "SELECT * FROM users WHERE id = 1 FOR UPDATE SKIP LOCKED",
108-
expectedWarmingQuery: "select * from users where id = 1",
107+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 FOR UPDATE SKIP LOCKED",
109108
},
110109
{
111110
name: "UNION FOR UPDATE",
112111
query: "SELECT * FROM users WHERE id = 1 UNION SELECT * FROM users WHERE id = 2 FOR UPDATE",
113-
expectedWarmingQuery: "select * from users where id = 1 union select * from users where id = 2",
112+
expectedWarmingQuery: "SELECT * FROM users WHERE id = 1 UNION SELECT * FROM users WHERE id = 2 FOR UPDATE",
114113
},
115114
{
116115
name: "Regular SELECT",
@@ -130,9 +129,6 @@ func TestWarmingReadsSkipsForUpdate(t *testing.T) {
130129
tc.query,
131130
"dummy_select_field",
132131
)
133-
// Parse and set QueryStatement to match how Routes are created in production
134-
parser, _ := sqlparser.NewTestParser().Parse(tc.query)
135-
route.QueryStatement = parser
136132
route.Vindex = vindex.(vindexes.SingleColumn)
137133
route.Values = []evalengine.Expr{
138134
evalengine.NewLiteralInt(1),
@@ -216,8 +212,6 @@ func TestWarmingReadsDroppedWhenChannelFull(t *testing.T) {
216212
"SELECT * FROM users WHERE id = 1",
217213
"dummy_select_field",
218214
)
219-
parser, _ := sqlparser.NewTestParser().Parse("SELECT * FROM users WHERE id = 1")
220-
route.QueryStatement = parser
221215
route.Vindex = vindex.(vindexes.SingleColumn)
222216
route.Values = []evalengine.Expr{
223217
evalengine.NewLiteralInt(1),
@@ -262,8 +256,6 @@ func TestWarmingReadsContextTimeout(t *testing.T) {
262256
"SELECT * FROM users WHERE id = 1",
263257
"dummy_select_field",
264258
)
265-
parser, _ := sqlparser.NewTestParser().Parse("SELECT * FROM users WHERE id = 1")
266-
route.QueryStatement = parser
267259
route.Vindex = vindex.(vindexes.SingleColumn)
268260
route.Values = []evalengine.Expr{
269261
evalengine.NewLiteralInt(1),

go/vt/vtgate/executorcontext/vcursor_impl.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,6 @@ func (vc *VCursorImpl) CloneForMirroring(ctx context.Context) engine.VCursor {
295295
}
296296

297297
func (vc *VCursorImpl) CloneForReplicaWarming(ctx context.Context) engine.VCursor {
298-
<<<<<<< HEAD
299-
callerId := callerid.EffectiveCallerIDFromContext(ctx)
300-
immediateCallerId := callerid.ImmediateCallerIDFromContext(ctx)
301-
302-
timedCtx, _ := context.WithTimeout(context.Background(), vc.config.WarmingReadsTimeout) // nolint
303-
clonedCtx := callerid.NewContext(timedCtx, callerId, immediateCallerId)
304-
305-
=======
306-
>>>>>>> 8c937df416 (VTGate: fix warming reads timeout context (#19674))
307298
v := &VCursorImpl{
308299
config: vc.config,
309300
SafeSession: NewAutocommitSession(vc.SafeSession.Session),
@@ -1351,6 +1342,7 @@ func (vc *VCursorImpl) AddAdvisoryLock(name string) {
13511342
func (vc *VCursorImpl) GetBindVars() map[string]*querypb.BindVariable {
13521343
return vc.bindVars
13531344
}
1345+
13541346
func (vc *VCursorImpl) SetBindVars(m map[string]*querypb.BindVariable) {
13551347
vc.bindVars = m
13561348
}

0 commit comments

Comments
 (0)