· 6 years ago · Sep 25, 2019, 05:14 PM
1diff --git a/go/cmd/mysqlctl/mysqlctl.go b/go/cmd/mysqlctl/mysqlctl.go
2index 2f39206a0..bf051d7e4 100644
3--- a/go/cmd/mysqlctl/mysqlctl.go
4+++ b/go/cmd/mysqlctl/mysqlctl.go
5@@ -25,6 +25,7 @@ import (
6
7 "golang.org/x/net/context"
8
9+ "vitess.io/vitess/go/context2"
10 "vitess.io/vitess/go/exit"
11 "vitess.io/vitess/go/flagutil"
12 "vitess.io/vitess/go/mysql"
13@@ -71,7 +72,7 @@ func initCmd(subFlags *flag.FlagSet, args []string) error {
14 }
15 defer mysqld.Close()
16
17- ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
18+ ctx, cancel := context2.WithTimeout(context.Background(), *waitTime, "./go/cmd/mysqlctl/mysqlctl.go:74")
19 defer cancel()
20 if err := mysqld.Init(ctx, cnf, *initDBSQLFile); err != nil {
21 return fmt.Errorf("failed init mysql: %v", err)
22@@ -104,7 +105,7 @@ func shutdownCmd(subFlags *flag.FlagSet, args []string) error {
23 }
24 defer mysqld.Close()
25
26- ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
27+ ctx, cancel := context2.WithTimeout(context.Background(), *waitTime, "./go/cmd/mysqlctl/mysqlctl.go:107")
28 defer cancel()
29 if err := mysqld.Shutdown(ctx, cnf, true); err != nil {
30 return fmt.Errorf("failed shutdown mysql: %v", err)
31@@ -125,7 +126,7 @@ func startCmd(subFlags *flag.FlagSet, args []string) error {
32 }
33 defer mysqld.Close()
34
35- ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
36+ ctx, cancel := context2.WithTimeout(context.Background(), *waitTime, "./go/cmd/mysqlctl/mysqlctl.go:128")
37 defer cancel()
38 if err := mysqld.Start(ctx, cnf, mysqldArgs...); err != nil {
39 return fmt.Errorf("failed start mysql: %v", err)
40@@ -145,7 +146,7 @@ func teardownCmd(subFlags *flag.FlagSet, args []string) error {
41 }
42 defer mysqld.Close()
43
44- ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
45+ ctx, cancel := context2.WithTimeout(context.Background(), *waitTime, "./go/cmd/mysqlctl/mysqlctl.go:148")
46 defer cancel()
47 if err := mysqld.Teardown(ctx, cnf, *force); err != nil {
48 return fmt.Errorf("failed teardown mysql (forced? %v): %v", *force, err)
49diff --git a/go/cmd/mysqlctld/mysqlctld.go b/go/cmd/mysqlctld/mysqlctld.go
50index 5c17ea813..8cafcb6fd 100644
51--- a/go/cmd/mysqlctld/mysqlctld.go
52+++ b/go/cmd/mysqlctld/mysqlctld.go
53@@ -25,6 +25,7 @@ import (
54 "time"
55
56 "golang.org/x/net/context"
57+ "vitess.io/vitess/go/context2"
58 "vitess.io/vitess/go/exit"
59 "vitess.io/vitess/go/vt/dbconfigs"
60 "vitess.io/vitess/go/vt/log"
61@@ -68,7 +69,7 @@ func main() {
62 }
63
64 // Start or Init mysqld as needed.
65- ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
66+ ctx, cancel := context2.WithTimeout(context.Background(), *waitTime, "./go/cmd/mysqlctld/mysqlctld.go:71")
67 mycnfFile := mysqlctl.MycnfFile(uint32(*tabletUID))
68 if _, statErr := os.Stat(mycnfFile); os.IsNotExist(statErr) {
69 // Generate my.cnf from scratch and use it to find mysqld.
70diff --git a/go/cmd/vtbackup/vtbackup.go b/go/cmd/vtbackup/vtbackup.go
71index 64ef47a96..7c8089105 100644
72--- a/go/cmd/vtbackup/vtbackup.go
73+++ b/go/cmd/vtbackup/vtbackup.go
74@@ -68,6 +68,7 @@ import (
75 "strings"
76 "time"
77
78+ "vitess.io/vitess/go/context2"
79 "vitess.io/vitess/go/exit"
80 "vitess.io/vitess/go/mysql"
81 "vitess.io/vitess/go/sqlescape"
82@@ -200,7 +201,7 @@ func takeBackup(ctx context.Context, topoServer *topo.Server, backupStorage back
83 if err != nil {
84 return fmt.Errorf("failed to initialize mysql config: %v", err)
85 }
86- initCtx, initCancel := context.WithTimeout(ctx, *mysqlTimeout)
87+ initCtx, initCancel := context2.WithTimeout(ctx, *mysqlTimeout, "./go/cmd/vtbackup/vtbackup.go:203")
88 defer initCancel()
89 if err := mysqld.Init(initCtx, mycnf, *initDBSQLFile); err != nil {
90 return fmt.Errorf("failed to initialize mysql data dir and start mysqld: %v", err)
91@@ -209,7 +210,7 @@ func takeBackup(ctx context.Context, topoServer *topo.Server, backupStorage back
92 defer func() {
93 // Be careful not to use the original context, because we don't want to
94 // skip shutdown just because we timed out waiting for other things.
95- ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
96+ ctx, cancel := context2.WithTimeout(context.Background(), 30*time.Second, "./go/cmd/vtbackup/vtbackup.go:212")
97 defer cancel()
98 mysqld.Shutdown(ctx, mycnf, false)
99 }()
100diff --git a/go/cmd/vtbench/vtbench.go b/go/cmd/vtbench/vtbench.go
101index 348299542..a7a548bb9 100644
102--- a/go/cmd/vtbench/vtbench.go
103+++ b/go/cmd/vtbench/vtbench.go
104@@ -23,6 +23,7 @@ import (
105 "strings"
106 "time"
107
108+ "vitess.io/vitess/go/context2"
109 "vitess.io/vitess/go/exit"
110 "vitess.io/vitess/go/vt/dbconfigs"
111 "vitess.io/vitess/go/vt/log"
112@@ -156,7 +157,7 @@ func main() {
113
114 b := vtbench.NewBench(*threads, *count, connParams, *sql)
115
116- ctx, cancel := context.WithTimeout(context.Background(), *deadline)
117+ ctx, cancel := context2.WithTimeout(context.Background(), *deadline, "./go/cmd/vtbench/vtbench.go:159")
118 defer cancel()
119
120 fmt.Printf("Initializing test with %s protocol / %d threads / %d iterations\n",
121diff --git a/go/cmd/vtclient/vtclient.go b/go/cmd/vtclient/vtclient.go
122index 87c6c4dc4..d89c3e3c1 100644
123--- a/go/cmd/vtclient/vtclient.go
124+++ b/go/cmd/vtclient/vtclient.go
125@@ -30,6 +30,7 @@ import (
126 "time"
127
128 "github.com/olekukonko/tablewriter"
129+ "vitess.io/vitess/go/context2"
130 "vitess.io/vitess/go/vt/concurrency"
131 "vitess.io/vitess/go/vt/log"
132 "vitess.io/vitess/go/vt/logutil"
133@@ -183,7 +184,7 @@ func run() (*results, error) {
134
135 log.Infof("Sending the query...")
136
137- ctx, cancel := context.WithTimeout(context.Background(), *timeout)
138+ ctx, cancel := context2.WithTimeout(context.Background(), *timeout, "./go/cmd/vtclient/vtclient.go:186")
139 defer cancel()
140 return execMulti(ctx, db, args[0])
141 }
142diff --git a/go/cmd/vtctl/vtctl.go b/go/cmd/vtctl/vtctl.go
143index 8365b9c0a..b8ebf5b4e 100644
144--- a/go/cmd/vtctl/vtctl.go
145+++ b/go/cmd/vtctl/vtctl.go
146@@ -27,6 +27,7 @@ import (
147 "time"
148
149 "golang.org/x/net/context"
150+ "vitess.io/vitess/go/context2"
151 "vitess.io/vitess/go/exit"
152 "vitess.io/vitess/go/trace"
153 "vitess.io/vitess/go/vt/log"
154@@ -91,7 +92,7 @@ func main() {
155
156 vtctl.WorkflowManager = workflow.NewManager(ts)
157
158- ctx, cancel := context.WithTimeout(context.Background(), *waitTime)
159+ ctx, cancel := context2.WithTimeout(context.Background(), *waitTime, "./go/cmd/vtctl/vtctl.go:94")
160 wr := wrangler.New(logutil.NewConsoleLogger(), ts, tmclient.NewTabletManagerClient())
161 installSignalHandlers(cancel)
162
163diff --git a/go/cmd/vtctlclient/main.go b/go/cmd/vtctlclient/main.go
164index f93696326..2279561b8 100644
165--- a/go/cmd/vtctlclient/main.go
166+++ b/go/cmd/vtctlclient/main.go
167@@ -23,6 +23,7 @@ import (
168 "time"
169
170 "golang.org/x/net/context"
171+ "vitess.io/vitess/go/context2"
172 "vitess.io/vitess/go/exit"
173 "vitess.io/vitess/go/trace"
174 "vitess.io/vitess/go/vt/log"
175@@ -55,7 +56,7 @@ func main() {
176 os.Exit(1)
177 }
178
179- ctx, cancel := context.WithTimeout(context.Background(), *actionTimeout)
180+ ctx, cancel := context2.WithTimeout(context.Background(), *actionTimeout, "./go/cmd/vtctlclient/main.go:58")
181 defer cancel()
182
183 err := vtctlclient.RunCommandAndWait(
184diff --git a/go/cmd/vtgateclienttest/services/echo.go b/go/cmd/vtgateclienttest/services/echo.go
185index ce7604124..6435324ea 100644
186--- a/go/cmd/vtgateclienttest/services/echo.go
187+++ b/go/cmd/vtgateclienttest/services/echo.go
188@@ -401,23 +401,23 @@ func (c *echoClient) VStream(ctx context.Context, tabletType topodatapb.TabletTy
189 if strings.HasPrefix(vgtid.ShardGtids[0].Shard, EchoPrefix) {
190 _ = callback([]*binlogdatapb.VEvent{
191 {
192- Type: 1,
193+ Type: 1,
194 Timestamp: 1234,
195- Gtid: "echo-gtid-1",
196- Ddl: "echo-ddl-1",
197- Vgtid: vgtid,
198+ Gtid: "echo-gtid-1",
199+ Ddl: "echo-ddl-1",
200+ Vgtid: vgtid,
201 RowEvent: &binlogdatapb.RowEvent{
202- TableName:"echo-table-1",
203+ TableName: "echo-table-1",
204 },
205 },
206 {
207- Type: 2,
208+ Type: 2,
209 Timestamp: 4321,
210- Gtid: "echo-gtid-2",
211- Ddl: "echo-ddl-2",
212- Vgtid: vgtid,
213+ Gtid: "echo-gtid-2",
214+ Ddl: "echo-ddl-2",
215+ Vgtid: vgtid,
216 FieldEvent: &binlogdatapb.FieldEvent{
217- TableName:"echo-table-2",
218+ TableName: "echo-table-2",
219 },
220 },
221 })
222diff --git a/go/cmd/vtqueryserver/plugin_grpcqueryservice.go b/go/cmd/vtqueryserver/plugin_grpcqueryservice.go
223index 60478f80a..b16cb0420 100644
224--- a/go/cmd/vtqueryserver/plugin_grpcqueryservice.go
225+++ b/go/cmd/vtqueryserver/plugin_grpcqueryservice.go
226@@ -24,7 +24,6 @@ import (
227 "vitess.io/vitess/go/vt/vttablet/tabletserver"
228 )
229
230-
231 func init() {
232 tabletserver.RegisterFunctions = append(tabletserver.RegisterFunctions, func(qsc tabletserver.Controller) {
233 if servenv.GRPCCheckServiceMap("queryservice") {
234diff --git a/go/cmd/vtworkerclient/vtworkerclient.go b/go/cmd/vtworkerclient/vtworkerclient.go
235index 0e1874453..59f434c9a 100644
236--- a/go/cmd/vtworkerclient/vtworkerclient.go
237+++ b/go/cmd/vtworkerclient/vtworkerclient.go
238@@ -23,6 +23,7 @@ import (
239 "syscall"
240
241 "golang.org/x/net/context"
242+ "vitess.io/vitess/go/context2"
243 "vitess.io/vitess/go/vt/log"
244 "vitess.io/vitess/go/vt/logutil"
245 "vitess.io/vitess/go/vt/worker/vtworkerclient"
246@@ -37,7 +38,7 @@ var (
247 func main() {
248 flag.Parse()
249
250- ctx, cancel := context.WithCancel(context.Background())
251+ ctx, cancel := context2.WithCancel(context.Background(), "./go/cmd/vtworkerclient/vtworkerclient.go:40")
252 defer cancel()
253 sigChan := make(chan os.Signal, 1)
254 signal.Notify(sigChan, syscall.SIGTERM, syscall.SIGINT)
255diff --git a/go/cmd/zk/zkcmd.go b/go/cmd/zk/zkcmd.go
256index c6cf45e6b..31663c0c0 100644
257--- a/go/cmd/zk/zkcmd.go
258+++ b/go/cmd/zk/zkcmd.go
259@@ -36,6 +36,7 @@ import (
260 "golang.org/x/crypto/ssh/terminal"
261 "golang.org/x/net/context"
262
263+ "vitess.io/vitess/go/context2"
264 "vitess.io/vitess/go/exit"
265 "vitess.io/vitess/go/vt/log"
266 "vitess.io/vitess/go/vt/logutil"
267@@ -157,7 +158,7 @@ func main() {
268 subFlags := flag.NewFlagSet(cmdName, flag.ExitOnError)
269
270 // Create a context for the command, cancel it if we get a signal.
271- ctx, cancel := context.WithCancel(context.Background())
272+ ctx, cancel := context2.WithCancel(context.Background(), "./go/cmd/zk/zkcmd.go:160")
273 sigRecv := make(chan os.Signal, 1)
274 signal.Notify(sigRecv, os.Interrupt)
275 go func() {
276diff --git a/go/context2/context.go b/go/context2/context.go
277new file mode 100644
278index 000000000..b4a03a28d
279--- /dev/null
280+++ b/go/context2/context.go
281@@ -0,0 +1,40 @@
282+package context2
283+
284+import (
285+ "context"
286+ "time"
287+
288+ "vitess.io/vitess/go/context2"
289+ "vitess.io/vitess/go/vt/log"
290+)
291+
292+type Context2 struct {
293+ context.Context
294+ reason string
295+}
296+
297+func WithCancel(parent context.Context, reason string) (context.Context, context.CancelFunc) {
298+ ctx, cancel := context2.WithCancel(parent, "./go/context2/context.go:15")
299+ ctx2 := Context2{ctx, reason}
300+ return ctx2, cancel
301+}
302+
303+func WithDeadline(parent context.Context, d time.Time, reason string) (context.Context, context.CancelFunc) {
304+ ctx, cancel := context2.WithDeadline(parent, d, "./go/context2/context.go:21")
305+ ctx2 := Context2{ctx, reason}
306+ return ctx2, cancel
307+}
308+
309+func WithTimeout(parent context.Context, timeout time.Duration, reason string) (context.Context, context.CancelFunc) {
310+ ctx, cancel := context2.WithTimeout(parent, timeout, "./go/context2/context.go:27")
311+ ctx2 := Context2{ctx, reason}
312+ return ctx2, cancel
313+}
314+
315+func (c Context2) Err() error {
316+ err := c.Context.Err()
317+ if err != nil {
318+ log.Infof("Context errored due to: %s", c.reason)
319+ }
320+ return err
321+}
322diff --git a/go/context2/context.go-E b/go/context2/context.go-E
323new file mode 100644
324index 000000000..63e15d80e
325--- /dev/null
326+++ b/go/context2/context.go-E
327@@ -0,0 +1,38 @@
328+package context2
329+
330+import (
331+ "context"
332+ "time"
333+ "vitess.io/vitess/go/vt/log"
334+)
335+
336+type Context2 struct {
337+ context.Context
338+ reason string
339+}
340+
341+func WithCancel(parent context.Context, reason string) (context.Context, context.CancelFunc) {
342+ ctx, cancel := context.WithCancel(parent)
343+ ctx2 := Context2{ctx, reason}
344+ return ctx2, cancel
345+}
346+
347+func WithDeadline(parent context.Context, d time.Time, reason string) (context.Context, context.CancelFunc) {
348+ ctx, cancel := context.WithDeadline(parent, d)
349+ ctx2 := Context2{ctx, reason}
350+ return ctx2, cancel
351+}
352+
353+func WithTimeout(parent context.Context, timeout time.Duration, reason string) (context.Context, context.CancelFunc) {
354+ ctx, cancel := context.WithTimeout(parent, timeout)
355+ ctx2 := Context2{ctx, reason}
356+ return ctx2, cancel
357+}
358+
359+func (c Context2) Err() error {
360+ err := c.Context.Err()
361+ if err != nil {
362+ log.Infof("Context errored due to: %s", c.reason)
363+ }
364+ return err
365+}
366diff --git a/go/mysql/client_test.go b/go/mysql/client_test.go
367index 13d25073e..3fa8aea13 100644
368--- a/go/mysql/client_test.go
369+++ b/go/mysql/client_test.go
370@@ -26,6 +26,7 @@ import (
371 "time"
372
373 "golang.org/x/net/context"
374+ "vitess.io/vitess/go/context2"
375 )
376
377 // assertSQLError makes sure we get the right error.
378@@ -71,7 +72,7 @@ func TestConnectTimeout(t *testing.T) {
379 defer listener.Close()
380
381 // Test that canceling the context really interrupts the Connect.
382- ctx, cancel := context.WithCancel(context.Background())
383+ ctx, cancel := context2.WithCancel(context.Background(), "./go/mysql/client_test.go:74")
384 done := make(chan struct{})
385 go func() {
386 _, err := Connect(ctx, params)
387@@ -85,7 +86,7 @@ func TestConnectTimeout(t *testing.T) {
388 <-done
389
390 // Tests a connection timeout works.
391- ctx, cancel = context.WithTimeout(context.Background(), 100*time.Millisecond)
392+ ctx, cancel = context2.WithTimeout(context.Background(), 100*time.Millisecond, "./go/mysql/client_test.go:88")
393 _, err = Connect(ctx, params)
394 cancel()
395 if err != context.DeadlineExceeded {
396diff --git a/go/mysql/server_test.go b/go/mysql/server_test.go
397index 49456128c..71d4e1199 100644
398--- a/go/mysql/server_test.go
399+++ b/go/mysql/server_test.go
400@@ -29,6 +29,7 @@ import (
401
402 "golang.org/x/net/context"
403
404+ "vitess.io/vitess/go/context2"
405 "vitess.io/vitess/go/sqltypes"
406 vtenv "vitess.io/vitess/go/vt/env"
407 "vitess.io/vitess/go/vt/tlstest"
408@@ -1246,7 +1247,7 @@ func TestListenerShutdown(t *testing.T) {
409 Pass: "password1",
410 }
411
412- ctx, cancel := context.WithCancel(context.Background())
413+ ctx, cancel := context2.WithCancel(context.Background(), "./go/mysql/server_test.go:1249")
414 defer cancel()
415
416 conn, err := Connect(ctx, params)
417diff --git a/go/pools/resource_pool.go b/go/pools/resource_pool.go
418index 8e92f0bf5..87c9caf09 100644
419--- a/go/pools/resource_pool.go
420+++ b/go/pools/resource_pool.go
421@@ -26,6 +26,7 @@ import (
422
423 "golang.org/x/net/context"
424
425+ "vitess.io/vitess/go/context2"
426 "vitess.io/vitess/go/sync2"
427 "vitess.io/vitess/go/timer"
428 "vitess.io/vitess/go/trace"
429@@ -100,7 +101,7 @@ func NewResourcePool(factory Factory, capacity, maxCap int, idleTimeout time.Dur
430 rp.resources <- resourceWrapper{}
431 }
432
433- ctx, cancel := context.WithTimeout(context.TODO(), prefillTimeout)
434+ ctx, cancel := context2.WithTimeout(context.TODO(), prefillTimeout, "./go/pools/resource_pool.go:103")
435 defer cancel()
436 if prefillParallelism != 0 {
437 sem := sync2.NewSemaphore(prefillParallelism, 0 /* timeout */)
438diff --git a/go/pools/resource_pool_test.go b/go/pools/resource_pool_test.go
439index 15c21c920..af8c80f9d 100644
440--- a/go/pools/resource_pool_test.go
441+++ b/go/pools/resource_pool_test.go
442@@ -22,6 +22,7 @@ import (
443 "time"
444
445 "golang.org/x/net/context"
446+ "vitess.io/vitess/go/context2"
447 "vitess.io/vitess/go/sync2"
448 )
449
450@@ -618,7 +619,7 @@ func TestTimeout(t *testing.T) {
451 if err != nil {
452 t.Fatal(err)
453 }
454- newctx, cancel := context.WithTimeout(ctx, 1*time.Millisecond)
455+ newctx, cancel := context2.WithTimeout(ctx, 1*time.Millisecond, "./go/pools/resource_pool_test.go:621")
456 _, err = p.Get(newctx)
457 cancel()
458 want := "resource pool timed out"
459@@ -633,7 +634,7 @@ func TestExpired(t *testing.T) {
460 count.Set(0)
461 p := NewResourcePool(PoolFactory, 1, 1, time.Second, 0)
462 defer p.Close()
463- ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(-1*time.Second))
464+ ctx, cancel := context2.WithDeadline(context.Background(), time.Now().Add(-1*time.Second), "./go/pools/resource_pool_test.go:636")
465 r, err := p.Get(ctx)
466 if err == nil {
467 p.Put(r)
468diff --git a/go/trace/opentracing.go b/go/trace/opentracing.go
469index 4413d808a..77f16c530 100644
470--- a/go/trace/opentracing.go
471+++ b/go/trace/opentracing.go
472@@ -17,7 +17,6 @@ package trace
473
474 import (
475 otgrpc "github.com/opentracing-contrib/go-grpc"
476- "github.com/opentracing/opentracing-go"
477 "golang.org/x/net/context"
478 "google.golang.org/grpc"
479 "vitess.io/vitess/go/vt/vterrors"
480diff --git a/go/trace/plugin_jaeger.go b/go/trace/plugin_jaeger.go
481index b8053a4e2..97ee7794a 100644
482--- a/go/trace/plugin_jaeger.go
483+++ b/go/trace/plugin_jaeger.go
484@@ -19,8 +19,6 @@ import (
485 "flag"
486 "io"
487
488- "github.com/opentracing/opentracing-go"
489- "github.com/uber/jaeger-client-go"
490 "github.com/uber/jaeger-client-go/config"
491 "vitess.io/vitess/go/vt/log"
492 )
493diff --git a/go/vt/binlog/binlog_streamer_test.go b/go/vt/binlog/binlog_streamer_test.go
494index 576e7b562..9a10fb38d 100644
495--- a/go/vt/binlog/binlog_streamer_test.go
496+++ b/go/vt/binlog/binlog_streamer_test.go
497@@ -26,6 +26,7 @@ import (
498 "github.com/golang/protobuf/proto"
499 "golang.org/x/net/context"
500
501+ "vitess.io/vitess/go/context2"
502 "vitess.io/vitess/go/mysql"
503
504 binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
505@@ -193,7 +194,7 @@ func TestStreamerStop(t *testing.T) {
506 bls := NewStreamer(&mysql.ConnParams{DbName: "vt_test_keyspace"}, nil, nil, mysql.Position{}, 0, sendTransaction)
507
508 // Start parseEvents(), but don't send it anything, so it just waits.
509- ctx, cancel := context.WithCancel(context.Background())
510+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/binlog/binlog_streamer_test.go:196")
511 done := make(chan error)
512 go func() {
513 _, err := bls.parseEvents(ctx, events)
514diff --git a/go/vt/binlog/binlogplayer/binlog_player_test.go b/go/vt/binlog/binlogplayer/binlog_player_test.go
515index dedcfcc08..f95aa2c0c 100644
516--- a/go/vt/binlog/binlogplayer/binlog_player_test.go
517+++ b/go/vt/binlog/binlogplayer/binlog_player_test.go
518@@ -22,6 +22,7 @@ import (
519 "time"
520
521 "golang.org/x/net/context"
522+ "vitess.io/vitess/go/context2"
523 "vitess.io/vitess/go/mysql"
524 "vitess.io/vitess/go/sqltypes"
525 "vitess.io/vitess/go/vt/throttler"
526@@ -306,7 +307,7 @@ func TestRetryOnDeadlock(t *testing.T) {
527 // has finished. Otherwise, it may cause race with other tests.
528 func applyEvents(blp *BinlogPlayer) func() error {
529 errChan := make(chan error)
530- ctx, cancel := context.WithCancel(context.Background())
531+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/binlog/binlogplayer/binlog_player_test.go:309")
532
533 go func() {
534 errChan <- blp.ApplyBinlogEvents(ctx)
535diff --git a/go/vt/binlog/slave_connection.go b/go/vt/binlog/slave_connection.go
536index c44d6e87f..a8d815aed 100644
537--- a/go/vt/binlog/slave_connection.go
538+++ b/go/vt/binlog/slave_connection.go
539@@ -22,6 +22,7 @@ import (
540
541 "golang.org/x/net/context"
542
543+ "vitess.io/vitess/go/context2"
544 "vitess.io/vitess/go/mysql"
545 "vitess.io/vitess/go/pools"
546 "vitess.io/vitess/go/vt/dbconfigs"
547@@ -96,7 +97,7 @@ var slaveIDPool = pools.NewIDPool()
548 // StartBinlogDumpFromCurrent requests a replication binlog dump from
549 // the current position.
550 func (sc *SlaveConnection) StartBinlogDumpFromCurrent(ctx context.Context) (mysql.Position, <-chan mysql.BinlogEvent, error) {
551- ctx, sc.cancel = context.WithCancel(ctx)
552+ ctx, sc.cancel = context2.WithCancel(ctx, "./go/vt/binlog/slave_connection.go:99")
553
554 masterPosition, err := sc.Conn.MasterPosition()
555 if err != nil {
556@@ -116,7 +117,7 @@ func (sc *SlaveConnection) StartBinlogDumpFromCurrent(ctx context.Context) (mysq
557 //
558 // Note the context is valid and used until eventChan is closed.
559 func (sc *SlaveConnection) StartBinlogDumpFromPosition(ctx context.Context, startPos mysql.Position) (<-chan mysql.BinlogEvent, error) {
560- ctx, sc.cancel = context.WithCancel(ctx)
561+ ctx, sc.cancel = context2.WithCancel(ctx, "./go/vt/binlog/slave_connection.go:119")
562
563 log.Infof("sending binlog dump command: startPos=%v, slaveID=%v", startPos, sc.slaveID)
564 if err := sc.SendBinlogDumpCommand(sc.slaveID, startPos); err != nil {
565@@ -192,7 +193,7 @@ func (sc *SlaveConnection) streamEvents(ctx context.Context) chan mysql.BinlogEv
566 //
567 // Note the context is valid and used until eventChan is closed.
568 func (sc *SlaveConnection) StartBinlogDumpFromBinlogBeforeTimestamp(ctx context.Context, timestamp int64) (<-chan mysql.BinlogEvent, error) {
569- ctx, sc.cancel = context.WithCancel(ctx)
570+ ctx, sc.cancel = context2.WithCancel(ctx, "./go/vt/binlog/slave_connection.go:195")
571
572 filename, err := sc.findFileBeforeTimestamp(ctx, timestamp)
573 if err != nil {
574diff --git a/go/vt/binlog/updatestreamctl.go b/go/vt/binlog/updatestreamctl.go
575index 3525c28a2..faea9bd5f 100644
576--- a/go/vt/binlog/updatestreamctl.go
577+++ b/go/vt/binlog/updatestreamctl.go
578@@ -22,6 +22,7 @@ import (
579
580 "golang.org/x/net/context"
581
582+ "vitess.io/vitess/go/context2"
583 "vitess.io/vitess/go/mysql"
584 "vitess.io/vitess/go/stats"
585 "vitess.io/vitess/go/sync2"
586@@ -266,7 +267,7 @@ func (updateStream *UpdateStreamImpl) StreamKeyRange(ctx context.Context, positi
587 return fmt.Errorf("newKeyspaceIDResolverFactory failed: %v", err)
588 }
589
590- streamCtx, cancel := context.WithCancel(ctx)
591+ streamCtx, cancel := context2.WithCancel(ctx, "./go/vt/binlog/updatestreamctl.go:269")
592 i := updateStream.streams.Add(cancel)
593 defer updateStream.streams.Delete(i)
594
595@@ -302,7 +303,7 @@ func (updateStream *UpdateStreamImpl) StreamTables(ctx context.Context, position
596 })
597 bls := NewStreamer(updateStream.cp, updateStream.se, charset, pos, 0, f)
598
599- streamCtx, cancel := context.WithCancel(ctx)
600+ streamCtx, cancel := context2.WithCancel(ctx, "./go/vt/binlog/updatestreamctl.go:305")
601 i := updateStream.streams.Add(cancel)
602 defer updateStream.streams.Delete(i)
603
604diff --git a/go/vt/discovery/healthcheck.go b/go/vt/discovery/healthcheck.go
605index 2e5e527b9..40a5d4e79 100644
606--- a/go/vt/discovery/healthcheck.go
607+++ b/go/vt/discovery/healthcheck.go
608@@ -51,6 +51,7 @@ import (
609
610 "github.com/golang/protobuf/proto"
611 "golang.org/x/net/context"
612+ "vitess.io/vitess/go/context2"
613 "vitess.io/vitess/go/netutil"
614 "vitess.io/vitess/go/stats"
615 "vitess.io/vitess/go/sync2"
616@@ -495,7 +496,7 @@ func (hc *HealthCheckImpl) finalizeConn(hcc *healthCheckConn) {
617 if hcc.conn != nil {
618 // Don't use hcc.ctx because it's already closed.
619 // Use a separate context, and add a timeout to prevent unbounded waits.
620- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
621+ ctx, cancel := context2.WithTimeout(context.Background(), 10*time.Second, "./go/vt/discovery/healthcheck.go:498")
622 defer cancel()
623 hcc.conn.Close(ctx)
624 hcc.conn = nil
625@@ -513,7 +514,7 @@ func (hc *HealthCheckImpl) checkConn(hcc *healthCheckConn, name string) {
626
627 retryDelay := hc.retryDelay
628 for {
629- streamCtx, streamCancel := context.WithCancel(hcc.ctx)
630+ streamCtx, streamCancel := context2.WithCancel(hcc.ctx, "./go/vt/discovery/healthcheck.go:516")
631
632 // Setup a watcher that restarts the timer every time an update is received.
633 // If a timeout occurs for a serving tablet, we make it non-serving and send
634@@ -715,7 +716,7 @@ func (hc *HealthCheckImpl) SetListener(listener HealthCheckStatsListener, sendDo
635 // It does not block on making connection.
636 // name is an optional tag for the tablet, e.g. an alternative address.
637 func (hc *HealthCheckImpl) AddTablet(tablet *topodatapb.Tablet, name string) {
638- ctx, cancelFunc := context.WithCancel(context.Background())
639+ ctx, cancelFunc := context2.WithCancel(context.Background(), "./go/vt/discovery/healthcheck.go:718")
640 key := TabletToMapKey(tablet)
641 hcc := &healthCheckConn{
642 ctx: ctx,
643diff --git a/go/vt/discovery/tablet_stats_cache_wait_test.go b/go/vt/discovery/tablet_stats_cache_wait_test.go
644index 19933494f..cffab6b4d 100644
645--- a/go/vt/discovery/tablet_stats_cache_wait_test.go
646+++ b/go/vt/discovery/tablet_stats_cache_wait_test.go
647@@ -22,6 +22,7 @@ import (
648
649 "golang.org/x/net/context"
650
651+ "vitess.io/vitess/go/context2"
652 "vitess.io/vitess/go/vt/topo"
653
654 querypb "vitess.io/vitess/go/vt/proto/query"
655@@ -29,7 +30,7 @@ import (
656 )
657
658 func TestWaitForTablets(t *testing.T) {
659- shortCtx, shortCancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
660+ shortCtx, shortCancel := context2.WithTimeout(context.Background(), 10*time.Millisecond, "./go/vt/discovery/tablet_stats_cache_wait_test.go:32")
661 defer shortCancel()
662 waitAvailableTabletInterval = 20 * time.Millisecond
663
664@@ -48,7 +49,7 @@ func TestWaitForTablets(t *testing.T) {
665 }
666
667 // this should fail, but return a non-timeout error
668- cancelledCtx, cancel := context.WithCancel(context.Background())
669+ cancelledCtx, cancel := context2.WithCancel(context.Background(), "./go/vt/discovery/tablet_stats_cache_wait_test.go:51")
670 cancel()
671 if err := tsc.WaitForTablets(cancelledCtx, "cell", "keyspace", "shard", topodatapb.TabletType_REPLICA); err == nil || err == context.DeadlineExceeded {
672 t.Errorf("want: non-timeout error, got: %v", err)
673@@ -67,7 +68,7 @@ func TestWaitForTablets(t *testing.T) {
674 input <- shr
675
676 // and ask again, with longer time outs so it's not flaky
677- longCtx, longCancel := context.WithTimeout(context.Background(), 10*time.Second)
678+ longCtx, longCancel := context2.WithTimeout(context.Background(), 10*time.Second, "./go/vt/discovery/tablet_stats_cache_wait_test.go:70")
679 defer longCancel()
680 waitAvailableTabletInterval = 10 * time.Millisecond
681 if err := tsc.WaitForTablets(longCtx, "cell", "keyspace", "shard", topodatapb.TabletType_REPLICA); err != nil {
682diff --git a/go/vt/discovery/topology_watcher.go b/go/vt/discovery/topology_watcher.go
683index 429b72f54..00d25363a 100644
684--- a/go/vt/discovery/topology_watcher.go
685+++ b/go/vt/discovery/topology_watcher.go
686@@ -26,6 +26,7 @@ import (
687 "time"
688
689 "golang.org/x/net/context"
690+ "vitess.io/vitess/go/context2"
691 "vitess.io/vitess/go/stats"
692 "vitess.io/vitess/go/trace"
693
694@@ -153,7 +154,7 @@ func NewTopologyWatcher(ctx context.Context, topoServer *topo.Server, tr TabletR
695
696 // We want the span from the context, but not the cancelation that comes with it
697 spanContext := trace.CopySpan(context.Background(), ctx)
698- tw.ctx, tw.cancelFunc = context.WithCancel(spanContext)
699+ tw.ctx, tw.cancelFunc = context2.WithCancel(spanContext, "./go/vt/discovery/topology_watcher.go:156")
700 tw.wg.Add(1)
701 go tw.watch()
702 return tw
703diff --git a/go/vt/grpcclient/client.go b/go/vt/grpcclient/client.go
704index 2ab77b011..62e270ab8 100644
705--- a/go/vt/grpcclient/client.go
706+++ b/go/vt/grpcclient/client.go
707@@ -21,8 +21,6 @@ package grpcclient
708 import (
709 "flag"
710
711- "github.com/grpc-ecosystem/go-grpc-middleware"
712- "github.com/grpc-ecosystem/go-grpc-prometheus"
713 "google.golang.org/grpc"
714 "google.golang.org/grpc/credentials"
715 "google.golang.org/grpc/keepalive"
716diff --git a/go/vt/grpcclient/client_test.go b/go/vt/grpcclient/client_test.go
717index 106a0937e..306040c04 100644
718--- a/go/vt/grpcclient/client_test.go
719+++ b/go/vt/grpcclient/client_test.go
720@@ -24,6 +24,7 @@ import (
721
722 "google.golang.org/grpc"
723
724+ "vitess.io/vitess/go/context2"
725 vtgatepb "vitess.io/vitess/go/vt/proto/vtgate"
726 vtgateservicepb "vitess.io/vitess/go/vt/proto/vtgateservice"
727 )
728@@ -41,7 +42,7 @@ func TestDialErrors(t *testing.T) {
729 t.Fatal(err)
730 }
731 vtg := vtgateservicepb.NewVitessClient(gconn)
732- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
733+ ctx, cancel := context2.WithTimeout(context.Background(), 10*time.Millisecond, "./go/vt/grpcclient/client_test.go:44")
734 _, err = vtg.Execute(ctx, &vtgatepb.ExecuteRequest{})
735 cancel()
736 gconn.Close()
737@@ -57,7 +58,7 @@ func TestDialErrors(t *testing.T) {
738 t.Fatal(err)
739 }
740 vtg := vtgateservicepb.NewVitessClient(gconn)
741- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
742+ ctx, cancel := context2.WithTimeout(context.Background(), 10*time.Millisecond, "./go/vt/grpcclient/client_test.go:60")
743 _, err = vtg.Execute(ctx, &vtgatepb.ExecuteRequest{})
744 cancel()
745 gconn.Close()
746diff --git a/go/vt/log/log.go b/go/vt/log/log.go
747index d2d0adf1d..9c61f1e7c 100644
748--- a/go/vt/log/log.go
749+++ b/go/vt/log/log.go
750@@ -7,6 +7,7 @@ package log
751
752 import (
753 "flag"
754+
755 "github.com/golang/glog"
756 )
757
758diff --git a/go/vt/mysqlctl/query.go b/go/vt/mysqlctl/query.go
759index 0051f5bd6..6759a367f 100644
760--- a/go/vt/mysqlctl/query.go
761+++ b/go/vt/mysqlctl/query.go
762@@ -23,6 +23,7 @@ import (
763
764 "golang.org/x/net/context"
765
766+ "vitess.io/vitess/go/context2"
767 "vitess.io/vitess/go/mysql"
768 "vitess.io/vitess/go/sqltypes"
769 "vitess.io/vitess/go/vt/dbconnpool"
770@@ -160,7 +161,7 @@ func (mysqld *Mysqld) killConnection(connID int64) error {
771 // Get another connection with which to kill.
772 // Use background context because the caller's context is likely expired,
773 // which is the reason we're being asked to kill the connection.
774- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
775+ ctx, cancel := context2.WithTimeout(context.Background(), 1*time.Second, "./go/vt/mysqlctl/query.go:163")
776 defer cancel()
777 if poolConn, connErr := getPoolReconnect(ctx, mysqld.dbaPool); connErr == nil {
778 // We got a pool connection.
779diff --git a/go/vt/schemamanager/schemaswap/schema_swap.go b/go/vt/schemamanager/schemaswap/schema_swap.go
780index 4aa4d3816..e485fa832 100644
781--- a/go/vt/schemamanager/schemaswap/schema_swap.go
782+++ b/go/vt/schemamanager/schemaswap/schema_swap.go
783@@ -29,6 +29,7 @@ import (
784
785 "golang.org/x/net/context"
786
787+ "vitess.io/vitess/go/context2"
788 "vitess.io/vitess/go/sqltypes"
789 "vitess.io/vitess/go/vt/concurrency"
790 "vitess.io/vitess/go/vt/discovery"
791@@ -879,7 +880,7 @@ func (array orderTabletsForSwap) Less(i, j int) bool {
792 // executeAdminQuery executes a query on a given tablet as 'allprivs' user. The query is executed
793 // using timeout value from --schema_swap_admin_query_timeout flag.
794 func (shardSwap *shardSchemaSwap) executeAdminQuery(tablet *topodatapb.Tablet, query string, maxRows int) (*sqltypes.Result, error) {
795- sqlCtx, cancelSQLCtx := context.WithTimeout(shardSwap.parent.ctx, *adminQueryTimeout)
796+ sqlCtx, cancelSQLCtx := context2.WithTimeout(shardSwap.parent.ctx, *adminQueryTimeout, "./go/vt/schemamanager/schemaswap/schema_swap.go:882")
797 defer cancelSQLCtx()
798
799 sqlResultProto, err := shardSwap.parent.tabletClient.ExecuteFetchAsAllPrivs(
800diff --git a/go/vt/schemamanager/tablet_executor.go b/go/vt/schemamanager/tablet_executor.go
801index 6346e6f91..a9738cb1f 100644
802--- a/go/vt/schemamanager/tablet_executor.go
803+++ b/go/vt/schemamanager/tablet_executor.go
804@@ -23,6 +23,7 @@ import (
805
806 "golang.org/x/net/context"
807
808+ "vitess.io/vitess/go/context2"
809 "vitess.io/vitess/go/sync2"
810 "vitess.io/vitess/go/vt/sqlparser"
811 "vitess.io/vitess/go/vt/wrangler"
812@@ -252,7 +253,7 @@ func (exec *TabletExecutor) executeOnAllTablets(ctx context.Context, execResult
813 // execute the schema change via replication. This is best-effort, meaning
814 // we still return overall success if the timeout expires.
815 concurrency := sync2.NewSemaphore(10, 0)
816- reloadCtx, cancel := context.WithTimeout(ctx, exec.waitSlaveTimeout)
817+ reloadCtx, cancel := context2.WithTimeout(ctx, exec.waitSlaveTimeout, "./go/vt/schemamanager/tablet_executor.go:255")
818 defer cancel()
819 for _, result := range execResult.SuccessShards {
820 wg.Add(1)
821diff --git a/go/vt/servenv/grpc_server_test.go b/go/vt/servenv/grpc_server_test.go
822index 8c611cf22..4a9cf034c 100644
823--- a/go/vt/servenv/grpc_server_test.go
824+++ b/go/vt/servenv/grpc_server_test.go
825@@ -17,62 +17,62 @@ limitations under the License.
826 package servenv
827
828 import (
829- "testing"
830+ "testing"
831
832- "golang.org/x/net/context"
833+ "golang.org/x/net/context"
834
835- "google.golang.org/grpc"
836+ "google.golang.org/grpc"
837 )
838
839 func TestEmpty(t *testing.T) {
840- interceptors := &serverInterceptorBuilder{}
841- if len(interceptors.Build()) > 0 {
842- t.Fatalf("expected empty builder to report as empty")
843- }
844+ interceptors := &serverInterceptorBuilder{}
845+ if len(interceptors.Build()) > 0 {
846+ t.Fatalf("expected empty builder to report as empty")
847+ }
848 }
849
850 func TestSingleInterceptor(t *testing.T) {
851- interceptors := &serverInterceptorBuilder{}
852- fake := &FakeInterceptor{}
853+ interceptors := &serverInterceptorBuilder{}
854+ fake := &FakeInterceptor{}
855
856- interceptors.Add(fake.StreamServerInterceptor, fake.UnaryServerInterceptor)
857+ interceptors.Add(fake.StreamServerInterceptor, fake.UnaryServerInterceptor)
858
859- if len(interceptors.streamInterceptors) != 1 {
860- t.Fatalf("expected 1 server options to be available")
861- }
862- if len(interceptors.unaryInterceptors) != 1 {
863- t.Fatalf("expected 1 server options to be available")
864- }
865+ if len(interceptors.streamInterceptors) != 1 {
866+ t.Fatalf("expected 1 server options to be available")
867+ }
868+ if len(interceptors.unaryInterceptors) != 1 {
869+ t.Fatalf("expected 1 server options to be available")
870+ }
871 }
872
873 func TestDoubleInterceptor(t *testing.T) {
874- interceptors := &serverInterceptorBuilder{}
875- fake1 := &FakeInterceptor{name: "ettan"}
876- fake2 := &FakeInterceptor{name: "tvaon"}
877-
878- interceptors.Add(fake1.StreamServerInterceptor, fake1.UnaryServerInterceptor)
879- interceptors.Add(fake2.StreamServerInterceptor, fake2.UnaryServerInterceptor)
880-
881- if len(interceptors.streamInterceptors) != 2 {
882- t.Fatalf("expected 1 server options to be available")
883- }
884- if len(interceptors.unaryInterceptors) != 2 {
885- t.Fatalf("expected 1 server options to be available")
886- }
887+ interceptors := &serverInterceptorBuilder{}
888+ fake1 := &FakeInterceptor{name: "ettan"}
889+ fake2 := &FakeInterceptor{name: "tvaon"}
890+
891+ interceptors.Add(fake1.StreamServerInterceptor, fake1.UnaryServerInterceptor)
892+ interceptors.Add(fake2.StreamServerInterceptor, fake2.UnaryServerInterceptor)
893+
894+ if len(interceptors.streamInterceptors) != 2 {
895+ t.Fatalf("expected 1 server options to be available")
896+ }
897+ if len(interceptors.unaryInterceptors) != 2 {
898+ t.Fatalf("expected 1 server options to be available")
899+ }
900 }
901
902 type FakeInterceptor struct {
903- name string
904- streamSeen interface{}
905- unarySeen interface{}
906+ name string
907+ streamSeen interface{}
908+ unarySeen interface{}
909 }
910
911 func (fake *FakeInterceptor) StreamServerInterceptor(value interface{}, stream grpc.ServerStream, _ *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
912- fake.streamSeen = value
913- return handler(value, stream)
914+ fake.streamSeen = value
915+ return handler(value, stream)
916 }
917
918 func (fake *FakeInterceptor) UnaryServerInterceptor(ctx context.Context, value interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
919- fake.unarySeen = value
920- return handler(ctx, value)
921+ fake.unarySeen = value
922+ return handler(ctx, value)
923 }
924diff --git a/go/vt/sqlparser/like_filter.go b/go/vt/sqlparser/like_filter.go
925index 598cb4911..411e906b3 100644
926--- a/go/vt/sqlparser/like_filter.go
927+++ b/go/vt/sqlparser/like_filter.go
928@@ -15,7 +15,7 @@ func replacer(s string) string {
929 return s[2:]
930 }
931
932- result := strings.Replace(s, "%" ,".*", -1)
933+ result := strings.Replace(s, "%", ".*", -1)
934 result = strings.Replace(result, "_", ".", -1)
935
936 return result
937diff --git a/go/vt/sqlparser/like_filter_test.go b/go/vt/sqlparser/like_filter_test.go
938index c44d6ff65..59687287c 100644
939--- a/go/vt/sqlparser/like_filter_test.go
940+++ b/go/vt/sqlparser/like_filter_test.go
941@@ -1,8 +1,9 @@
942 package sqlparser
943
944 import (
945- "github.com/stretchr/testify/assert"
946 "testing"
947+
948+ "github.com/stretchr/testify/assert"
949 )
950
951 func TestEmptyLike(t *testing.T) {
952diff --git a/go/vt/srvtopo/resilient_server_flaky_test.go b/go/vt/srvtopo/resilient_server_flaky_test.go
953index e40d9500c..b21ae1883 100644
954--- a/go/vt/srvtopo/resilient_server_flaky_test.go
955+++ b/go/vt/srvtopo/resilient_server_flaky_test.go
956@@ -27,6 +27,7 @@ import (
957
958 "github.com/golang/protobuf/proto"
959 "golang.org/x/net/context"
960+ "vitess.io/vitess/go/context2"
961 "vitess.io/vitess/go/vt/status"
962 "vitess.io/vitess/go/vt/topo"
963 "vitess.io/vitess/go/vt/topo/memorytopo"
964@@ -308,7 +309,7 @@ func TestGetSrvKeyspace(t *testing.T) {
965
966 time.Sleep(*srvTopoCacheTTL)
967
968- timeoutCtx, _ := context.WithTimeout(context.Background(), *srvTopoCacheRefresh*2)
969+ timeoutCtx, _ := context2.WithTimeout(context.Background(), *srvTopoCacheRefresh*2, "./go/vt/srvtopo/resilient_server_flaky_test.go:311")
970 _, err = rs.GetSrvKeyspace(timeoutCtx, "test_cell", "test_ks")
971 wantErr := "timed out waiting for keyspace"
972 if err == nil || err.Error() != wantErr {
973@@ -346,7 +347,7 @@ func TestSrvKeyspaceCachedError(t *testing.T) {
974 time.Sleep(*srvTopoCacheTTL + 10*time.Millisecond)
975 // Ask again with a different context, should get an error and
976 // save that context.
977- ctx, cancel := context.WithCancel(ctx)
978+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/srvtopo/resilient_server_flaky_test.go:349")
979 defer cancel()
980 _, err2 := rs.GetSrvKeyspace(ctx, "test_cell", "unknown_ks")
981 if err2 == nil {
982@@ -598,7 +599,7 @@ func TestGetSrvKeyspaceNames(t *testing.T) {
983
984 time.Sleep(*srvTopoCacheTTL)
985
986- timeoutCtx, _ := context.WithTimeout(context.Background(), *srvTopoCacheRefresh*2)
987+ timeoutCtx, _ := context2.WithTimeout(context.Background(), *srvTopoCacheRefresh*2, "./go/vt/srvtopo/resilient_server_flaky_test.go:601")
988 _, err = rs.GetSrvKeyspaceNames(timeoutCtx, "test_cell")
989 wantErr := "timed out waiting for keyspace names"
990 if err == nil || err.Error() != wantErr {
991diff --git a/go/vt/topo/consultopo/election.go b/go/vt/topo/consultopo/election.go
992index bacbbac8d..65455b1c8 100644
993--- a/go/vt/topo/consultopo/election.go
994+++ b/go/vt/topo/consultopo/election.go
995@@ -22,6 +22,7 @@ import (
996 "golang.org/x/net/context"
997
998 "github.com/hashicorp/consul/api"
999+ "vitess.io/vitess/go/context2"
1000 "vitess.io/vitess/go/vt/log"
1001 "vitess.io/vitess/go/vt/topo"
1002 )
1003@@ -90,7 +91,7 @@ func (mp *consulMasterParticipation) WaitForMastership() (context.Context, error
1004 }
1005
1006 // We have the lock, keep mastership until we lose it.
1007- lockCtx, lockCancel := context.WithCancel(context.Background())
1008+ lockCtx, lockCancel := context2.WithCancel(context.Background(), "./go/vt/topo/consultopo/election.go:93")
1009 go func() {
1010 select {
1011 case <-lost:
1012diff --git a/go/vt/topo/consultopo/watch.go b/go/vt/topo/consultopo/watch.go
1013index 8021738ca..de4ca89b9 100644
1014--- a/go/vt/topo/consultopo/watch.go
1015+++ b/go/vt/topo/consultopo/watch.go
1016@@ -24,6 +24,7 @@ import (
1017 "golang.org/x/net/context"
1018
1019 "github.com/hashicorp/consul/api"
1020+ "vitess.io/vitess/go/context2"
1021 "vitess.io/vitess/go/vt/topo"
1022 )
1023
1024@@ -51,7 +52,7 @@ func (s *Server) Watch(ctx context.Context, filePath string) (*topo.WatchData, <
1025 }
1026
1027 // Create a context, will be used to cancel the watch.
1028- watchCtx, watchCancel := context.WithCancel(context.Background())
1029+ watchCtx, watchCancel := context2.WithCancel(context.Background(), "./go/vt/topo/consultopo/watch.go:54")
1030
1031 // Create the notifications channel, send updates to it.
1032 notifications := make(chan *topo.WatchData, 10)
1033diff --git a/go/vt/topo/etcd2topo/election.go b/go/vt/topo/etcd2topo/election.go
1034index 354c5e499..ff3b66256 100644
1035--- a/go/vt/topo/etcd2topo/election.go
1036+++ b/go/vt/topo/etcd2topo/election.go
1037@@ -22,6 +22,7 @@ import (
1038 "github.com/coreos/etcd/clientv3"
1039 "golang.org/x/net/context"
1040
1041+ "vitess.io/vitess/go/context2"
1042 "vitess.io/vitess/go/vt/log"
1043 "vitess.io/vitess/go/vt/topo"
1044 )
1045@@ -73,7 +74,7 @@ func (mp *etcdMasterParticipation) WaitForMastership() (context.Context, error)
1046
1047 // We use a cancelable context here. If stop is closed,
1048 // we just cancel that context.
1049- lockCtx, lockCancel := context.WithCancel(context.Background())
1050+ lockCtx, lockCancel := context2.WithCancel(context.Background(), "./go/vt/topo/etcd2topo/election.go:76")
1051 go func() {
1052 <-mp.stop
1053 if ld != nil {
1054diff --git a/go/vt/topo/etcd2topo/lock.go b/go/vt/topo/etcd2topo/lock.go
1055index 27928cf3e..7f916239e 100644
1056--- a/go/vt/topo/etcd2topo/lock.go
1057+++ b/go/vt/topo/etcd2topo/lock.go
1058@@ -24,6 +24,7 @@ import (
1059 "github.com/coreos/etcd/clientv3"
1060 "github.com/coreos/etcd/mvcc/mvccpb"
1061 "golang.org/x/net/context"
1062+ "vitess.io/vitess/go/context2"
1063 "vitess.io/vitess/go/vt/proto/vtrpc"
1064 "vitess.io/vitess/go/vt/vterrors"
1065
1066@@ -86,7 +87,7 @@ func (s *Server) waitOnLastRev(ctx context.Context, cli *clientv3.Client, nodePa
1067 // Wait for release on blocking key. Cancel the watch when we
1068 // exit this function.
1069 key := string(lastKey.Kvs[0].Key)
1070- ctx, cancel := context.WithCancel(ctx)
1071+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/topo/etcd2topo/lock.go:89")
1072 defer cancel()
1073 wc := cli.Watch(ctx, key, clientv3.WithRev(revision))
1074 if wc == nil {
1075diff --git a/go/vt/topo/etcd2topo/server_test.go b/go/vt/topo/etcd2topo/server_test.go
1076index beccd612b..920686bc2 100644
1077--- a/go/vt/topo/etcd2topo/server_test.go
1078+++ b/go/vt/topo/etcd2topo/server_test.go
1079@@ -28,6 +28,7 @@ import (
1080 "golang.org/x/net/context"
1081
1082 "github.com/coreos/etcd/clientv3"
1083+ "vitess.io/vitess/go/context2"
1084 "vitess.io/vitess/go/testfiles"
1085 "vitess.io/vitess/go/vt/topo"
1086 "vitess.io/vitess/go/vt/topo/test"
1087@@ -73,7 +74,7 @@ func startEtcd(t *testing.T) (*exec.Cmd, string, string) {
1088 }
1089
1090 // Wait until we can list "/", or timeout.
1091- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
1092+ ctx, cancel := context2.WithTimeout(context.Background(), 10*time.Second, "./go/vt/topo/etcd2topo/server_test.go:76")
1093 defer cancel()
1094 start := time.Now()
1095 for {
1096diff --git a/go/vt/topo/etcd2topo/watch.go b/go/vt/topo/etcd2topo/watch.go
1097index 706fd994e..cb024798c 100644
1098--- a/go/vt/topo/etcd2topo/watch.go
1099+++ b/go/vt/topo/etcd2topo/watch.go
1100@@ -23,6 +23,7 @@ import (
1101 "github.com/coreos/etcd/clientv3"
1102 "github.com/coreos/etcd/mvcc/mvccpb"
1103 "golang.org/x/net/context"
1104+ "vitess.io/vitess/go/context2"
1105 "vitess.io/vitess/go/vt/proto/vtrpc"
1106 "vitess.io/vitess/go/vt/vterrors"
1107
1108@@ -50,10 +51,10 @@ func (s *Server) Watch(ctx context.Context, filePath string) (*topo.WatchData, <
1109 }
1110
1111 // Create an outer context that will be canceled on return and will cancel all inner watches.
1112- outerCtx, outerCancel := context.WithCancel(context.Background())
1113+ outerCtx, outerCancel := context2.WithCancel(context.Background(), "./go/vt/topo/etcd2topo/watch.go:53")
1114
1115 // Create a context, will be used to cancel the watch on retry.
1116- watchCtx, watchCancel := context.WithCancel(outerCtx)
1117+ watchCtx, watchCancel := context2.WithCancel(outerCtx, "./go/vt/topo/etcd2topo/watch.go:56")
1118
1119 // Create the Watcher. We start watching from the response we
1120 // got, not from the file original version, as the server may
1121@@ -87,7 +88,7 @@ func (s *Server) Watch(ctx context.Context, filePath string) (*topo.WatchData, <
1122 watchRetries++
1123 // Cancel inner context on retry and create new one.
1124 watchCancel()
1125- watchCtx, watchCancel = context.WithCancel(outerCtx)
1126+ watchCtx, watchCancel = context2.WithCancel(outerCtx, "./go/vt/topo/etcd2topo/watch.go:90")
1127 newWatcher := s.cli.Watch(watchCtx, nodePath, clientv3.WithRev(currVersion))
1128 if newWatcher == nil {
1129 log.Warningf("watch %v failed and get a nil channel returned, currVersion: %v", nodePath, currVersion)
1130diff --git a/go/vt/topo/locks.go b/go/vt/topo/locks.go
1131index f9f15a479..184e505e5 100644
1132--- a/go/vt/topo/locks.go
1133+++ b/go/vt/topo/locks.go
1134@@ -26,6 +26,7 @@ import (
1135 "time"
1136
1137 "golang.org/x/net/context"
1138+ "vitess.io/vitess/go/context2"
1139 "vitess.io/vitess/go/vt/proto/vtrpc"
1140 "vitess.io/vitess/go/vt/vterrors"
1141
1142@@ -217,7 +218,7 @@ func CheckKeyspaceLocked(ctx context.Context, keyspace string) error {
1143 func (l *Lock) lockKeyspace(ctx context.Context, ts *Server, keyspace string) (LockDescriptor, error) {
1144 log.Infof("Locking keyspace %v for action %v", keyspace, l.Action)
1145
1146- ctx, cancel := context.WithTimeout(ctx, *RemoteOperationTimeout)
1147+ ctx, cancel := context2.WithTimeout(ctx, *RemoteOperationTimeout, "./go/vt/topo/locks.go:220")
1148 defer cancel()
1149
1150 span, ctx := trace.NewSpan(ctx, "TopoServer.LockKeyspaceForAction")
1151@@ -241,7 +242,7 @@ func (l *Lock) unlockKeyspace(ctx context.Context, ts *Server, keyspace string,
1152 // Note that we are not using the user provided RemoteOperationTimeout
1153 // here because it is possible that that timeout is too short.
1154 ctx = trace.CopySpan(context.TODO(), ctx)
1155- ctx, cancel := context.WithTimeout(ctx, defaultLockTimeout)
1156+ ctx, cancel := context2.WithTimeout(ctx, defaultLockTimeout, "./go/vt/topo/locks.go:244")
1157 defer cancel()
1158
1159 span, ctx := trace.NewSpan(ctx, "TopoServer.UnlockKeyspaceForAction")
1160@@ -358,7 +359,7 @@ func CheckShardLocked(ctx context.Context, keyspace, shard string) error {
1161 func (l *Lock) lockShard(ctx context.Context, ts *Server, keyspace, shard string) (LockDescriptor, error) {
1162 log.Infof("Locking shard %v/%v for action %v", keyspace, shard, l.Action)
1163
1164- ctx, cancel := context.WithTimeout(ctx, *RemoteOperationTimeout)
1165+ ctx, cancel := context2.WithTimeout(ctx, *RemoteOperationTimeout, "./go/vt/topo/locks.go:361")
1166 defer cancel()
1167
1168 span, ctx := trace.NewSpan(ctx, "TopoServer.LockShardForAction")
1169@@ -382,7 +383,7 @@ func (l *Lock) unlockShard(ctx context.Context, ts *Server, keyspace, shard stri
1170 // Note that we are not using the user provided RemoteOperationTimeout
1171 // here because it is possible that that timeout is too short.
1172 ctx = trace.CopySpan(context.TODO(), ctx)
1173- ctx, cancel := context.WithTimeout(ctx, defaultLockTimeout)
1174+ ctx, cancel := context2.WithTimeout(ctx, defaultLockTimeout, "./go/vt/topo/locks.go:385")
1175 defer cancel()
1176
1177 span, ctx := trace.NewSpan(ctx, "TopoServer.UnlockShardForAction")
1178diff --git a/go/vt/topo/memorytopo/election.go b/go/vt/topo/memorytopo/election.go
1179index f66154a02..16db7ccb7 100644
1180--- a/go/vt/topo/memorytopo/election.go
1181+++ b/go/vt/topo/memorytopo/election.go
1182@@ -21,6 +21,7 @@ import (
1183
1184 "golang.org/x/net/context"
1185
1186+ "vitess.io/vitess/go/context2"
1187 "vitess.io/vitess/go/vt/log"
1188 "vitess.io/vitess/go/vt/topo"
1189 )
1190@@ -81,7 +82,7 @@ func (mp *cMasterParticipation) WaitForMastership() (context.Context, error) {
1191
1192 // We use a cancelable context here. If stop is closed,
1193 // we just cancel that context.
1194- lockCtx, lockCancel := context.WithCancel(context.Background())
1195+ lockCtx, lockCancel := context2.WithCancel(context.Background(), "./go/vt/topo/memorytopo/election.go:84")
1196 go func() {
1197 <-mp.stop
1198 if ld != nil {
1199diff --git a/go/vt/topo/test/lock.go b/go/vt/topo/test/lock.go
1200index 315653ff0..ab5e60043 100644
1201--- a/go/vt/topo/test/lock.go
1202+++ b/go/vt/topo/test/lock.go
1203@@ -22,6 +22,7 @@ import (
1204 "time"
1205
1206 "golang.org/x/net/context"
1207+ "vitess.io/vitess/go/context2"
1208 "vitess.io/vitess/go/vt/topo"
1209
1210 topodatapb "vitess.io/vitess/go/vt/proto/topodata"
1211@@ -92,14 +93,14 @@ func checkLockTimeout(ctx context.Context, t *testing.T, conn topo.Conn) {
1212 }
1213
1214 // test we can't take the lock again
1215- fastCtx, cancel := context.WithTimeout(ctx, timeUntilLockIsTaken)
1216+ fastCtx, cancel := context2.WithTimeout(ctx, timeUntilLockIsTaken, "./go/vt/topo/test/lock.go:95")
1217 if _, err := conn.Lock(fastCtx, keyspacePath, "again"); !topo.IsErrType(err, topo.Timeout) {
1218 t.Fatalf("Lock(again): %v", err)
1219 }
1220 cancel()
1221
1222 // test we can interrupt taking the lock
1223- interruptCtx, cancel := context.WithCancel(ctx)
1224+ interruptCtx, cancel := context2.WithCancel(ctx, "./go/vt/topo/test/lock.go:102")
1225 go func() {
1226 time.Sleep(timeUntilLockIsTaken)
1227 cancel()
1228diff --git a/go/vt/topo/zk2topo/election.go b/go/vt/topo/zk2topo/election.go
1229index 15975a00f..df408f41e 100644
1230--- a/go/vt/topo/zk2topo/election.go
1231+++ b/go/vt/topo/zk2topo/election.go
1232@@ -22,6 +22,7 @@ import (
1233
1234 "github.com/z-division/go-zookeeper/zk"
1235 "golang.org/x/net/context"
1236+ "vitess.io/vitess/go/context2"
1237 "vitess.io/vitess/go/vt/vterrors"
1238
1239 "vitess.io/vitess/go/vt/log"
1240@@ -49,7 +50,7 @@ func (zs *Server) NewMasterParticipation(name, id string) (topo.MasterParticipat
1241 id: []byte(id),
1242 done: make(chan struct{}),
1243 }
1244- result.stopCtx, result.stopCtxCancel = context.WithCancel(context.Background())
1245+ result.stopCtx, result.stopCtxCancel = context2.WithCancel(context.Background(), "./go/vt/topo/zk2topo/election.go:52")
1246 return result, nil
1247 }
1248
1249@@ -122,7 +123,7 @@ func (mp *zkMasterParticipation) WaitForMastership() (context.Context, error) {
1250 }
1251
1252 // we got the lock, create our background context
1253- ctx, cancel := context.WithCancel(context.Background())
1254+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/topo/zk2topo/election.go:125")
1255 go mp.watchMastership(ctx, mp.zs.conn, proposal, cancel)
1256 return ctx, nil
1257 }
1258diff --git a/go/vt/vtctl/throttler.go b/go/vt/vtctl/throttler.go
1259index 1e8452e57..1822f42d5 100644
1260--- a/go/vt/vtctl/throttler.go
1261+++ b/go/vt/vtctl/throttler.go
1262@@ -27,6 +27,7 @@ import (
1263 "github.com/olekukonko/tablewriter"
1264 "golang.org/x/net/context"
1265
1266+ "vitess.io/vitess/go/context2"
1267 "vitess.io/vitess/go/vt/logutil"
1268 "vitess.io/vitess/go/vt/throttler"
1269 "vitess.io/vitess/go/vt/throttler/throttlerclient"
1270@@ -86,7 +87,7 @@ func commandThrottlerMaxRates(ctx context.Context, wr *wrangler.Wrangler, subFla
1271 }
1272
1273 // Connect to the server.
1274- ctx, cancel := context.WithTimeout(ctx, shortTimeout)
1275+ ctx, cancel := context2.WithTimeout(ctx, shortTimeout, "./go/vt/vtctl/throttler.go:89")
1276 defer cancel()
1277 client, err := throttlerclient.New(*server)
1278 if err != nil {
1279@@ -139,7 +140,7 @@ func commandThrottlerSetMaxRate(ctx context.Context, wr *wrangler.Wrangler, subF
1280 }
1281
1282 // Connect to the server.
1283- ctx, cancel := context.WithTimeout(ctx, shortTimeout)
1284+ ctx, cancel := context2.WithTimeout(ctx, shortTimeout, "./go/vt/vtctl/throttler.go:142")
1285 defer cancel()
1286 client, err := throttlerclient.New(*server)
1287 if err != nil {
1288@@ -176,7 +177,7 @@ func commandGetThrottlerConfiguration(ctx context.Context, wr *wrangler.Wrangler
1289 }
1290
1291 // Connect to the server.
1292- ctx, cancel := context.WithTimeout(ctx, shortTimeout)
1293+ ctx, cancel := context2.WithTimeout(ctx, shortTimeout, "./go/vt/vtctl/throttler.go:179")
1294 defer cancel()
1295 client, err := throttlerclient.New(*server)
1296 if err != nil {
1297@@ -230,7 +231,7 @@ func commandUpdateThrottlerConfiguration(ctx context.Context, wr *wrangler.Wrang
1298 }
1299
1300 // Connect to the server.
1301- ctx, cancel := context.WithTimeout(ctx, shortTimeout)
1302+ ctx, cancel := context2.WithTimeout(ctx, shortTimeout, "./go/vt/vtctl/throttler.go:233")
1303 defer cancel()
1304 client, err := throttlerclient.New(*server)
1305 if err != nil {
1306@@ -268,7 +269,7 @@ func commandResetThrottlerConfiguration(ctx context.Context, wr *wrangler.Wrangl
1307 }
1308
1309 // Connect to the server.
1310- ctx, cancel := context.WithTimeout(ctx, shortTimeout)
1311+ ctx, cancel := context2.WithTimeout(ctx, shortTimeout, "./go/vt/vtctl/throttler.go:271")
1312 defer cancel()
1313 client, err := throttlerclient.New(*server)
1314 if err != nil {
1315diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go
1316index 94cb8744a..f935fd7db 100644
1317--- a/go/vt/vtctl/vtctl.go
1318+++ b/go/vt/vtctl/vtctl.go
1319@@ -107,6 +107,7 @@ import (
1320 "github.com/golang/protobuf/proto"
1321 "golang.org/x/net/context"
1322
1323+ "vitess.io/vitess/go/context2"
1324 "vitess.io/vitess/go/flagutil"
1325 "vitess.io/vitess/go/json2"
1326 "vitess.io/vitess/go/mysql"
1327@@ -1010,7 +1011,7 @@ func commandWaitForDrain(ctx context.Context, wr *wrangler.Wrangler, subFlags *f
1328 }
1329 if *timeout != 0 {
1330 var cancel context.CancelFunc
1331- ctx, cancel = context.WithTimeout(ctx, *timeout)
1332+ ctx, cancel = context2.WithTimeout(ctx, *timeout, "./go/vt/vtctl/vtctl.go:1013")
1333 defer cancel()
1334 }
1335
1336diff --git a/go/vt/vtctld/action_repository.go b/go/vt/vtctld/action_repository.go
1337index 7b484707e..c957b3280 100644
1338--- a/go/vt/vtctld/action_repository.go
1339+++ b/go/vt/vtctld/action_repository.go
1340@@ -24,6 +24,7 @@ import (
1341 "golang.org/x/net/context"
1342
1343 "vitess.io/vitess/go/acl"
1344+ "vitess.io/vitess/go/context2"
1345 "vitess.io/vitess/go/vt/logutil"
1346 "vitess.io/vitess/go/vt/topo"
1347 "vitess.io/vitess/go/vt/topo/topoproto"
1348@@ -115,7 +116,7 @@ func (ar *ActionRepository) ApplyKeyspaceAction(ctx context.Context, actionName,
1349 return result
1350 }
1351
1352- ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
1353+ ctx, cancel := context2.WithTimeout(ctx, *actionTimeout, "./go/vt/vtctld/action_repository.go:118")
1354 wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
1355 output, err := action(ctx, wr, keyspace, r)
1356 cancel()
1357@@ -142,7 +143,7 @@ func (ar *ActionRepository) ApplyShardAction(ctx context.Context, actionName, ke
1358 return result
1359 }
1360
1361- ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
1362+ ctx, cancel := context2.WithTimeout(ctx, *actionTimeout, "./go/vt/vtctld/action_repository.go:145")
1363 wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
1364 output, err := action(ctx, wr, keyspace, shard, r)
1365 cancel()
1366@@ -176,7 +177,7 @@ func (ar *ActionRepository) ApplyTabletAction(ctx context.Context, actionName st
1367 }
1368
1369 // run the action
1370- ctx, cancel := context.WithTimeout(ctx, *actionTimeout)
1371+ ctx, cancel := context2.WithTimeout(ctx, *actionTimeout, "./go/vt/vtctld/action_repository.go:179")
1372 wr := wrangler.New(logutil.NewConsoleLogger(), ar.ts, tmclient.NewTabletManagerClient())
1373 output, err := action.method(ctx, wr, tabletAlias, r)
1374 cancel()
1375diff --git a/go/vt/vtctld/tablet_data_test.go b/go/vt/vtctld/tablet_data_test.go
1376index edc69d985..e8b32d2d2 100644
1377--- a/go/vt/vtctld/tablet_data_test.go
1378+++ b/go/vt/vtctld/tablet_data_test.go
1379@@ -24,6 +24,7 @@ import (
1380
1381 "github.com/golang/protobuf/proto"
1382 "golang.org/x/net/context"
1383+ "vitess.io/vitess/go/context2"
1384 "vitess.io/vitess/go/vt/logutil"
1385 querypb "vitess.io/vitess/go/vt/proto/query"
1386 topodatapb "vitess.io/vitess/go/vt/proto/topodata"
1387@@ -141,7 +142,7 @@ func TestTabletData(t *testing.T) {
1388 }()
1389
1390 // Start streaming and wait for the first result.
1391- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
1392+ ctx, cancel := context2.WithTimeout(context.Background(), 5*time.Second, "./go/vt/vtctld/tablet_data_test.go:144")
1393 result, err := thc.Get(ctx, tablet1.Tablet.Alias)
1394 cancel()
1395 close(stop)
1396diff --git a/go/vt/vtctld/workflow.go b/go/vt/vtctld/workflow.go
1397index 1982e9093..e95b4a5fc 100644
1398--- a/go/vt/vtctld/workflow.go
1399+++ b/go/vt/vtctld/workflow.go
1400@@ -21,6 +21,7 @@ import (
1401 "time"
1402
1403 "golang.org/x/net/context"
1404+ "vitess.io/vitess/go/context2"
1405 "vitess.io/vitess/go/trace"
1406
1407 "vitess.io/vitess/go/flagutil"
1408@@ -85,7 +86,7 @@ func initWorkflowManager(ts *topo.Server) {
1409 }
1410
1411 func runWorkflowManagerAlone() {
1412- ctx, cancel := context.WithCancel(context.Background())
1413+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtctld/workflow.go:88")
1414 go vtctl.WorkflowManager.Run(ctx)
1415
1416 // Running cancel on OnTermSync will cancel the context of any
1417diff --git a/go/vt/vtgate/buffer/buffer_test.go b/go/vt/vtgate/buffer/buffer_test.go
1418index 5951ebb65..f4d7074e2 100644
1419--- a/go/vt/vtgate/buffer/buffer_test.go
1420+++ b/go/vt/vtgate/buffer/buffer_test.go
1421@@ -26,6 +26,7 @@ import (
1422
1423 "golang.org/x/net/context"
1424
1425+ "vitess.io/vitess/go/context2"
1426 "vitess.io/vitess/go/vt/discovery"
1427 "vitess.io/vitess/go/vt/topo/topoproto"
1428 "vitess.io/vitess/go/vt/vterrors"
1429@@ -574,7 +575,7 @@ func testRequestCanceled(t *testing.T, explicitEnd bool) {
1430 if err := waitForRequestsInFlight(b, 1); err != nil {
1431 t.Fatal(err)
1432 }
1433- ctx2, cancel2 := context.WithCancel(context.Background())
1434+ ctx2, cancel2 := context2.WithCancel(context.Background(), "./go/vt/vtgate/buffer/buffer_test.go:577")
1435 stopped2 := issueRequest(ctx2, t, b, failoverErr)
1436 if err := waitForRequestsInFlight(b, 2); err != nil {
1437 t.Fatal(err)
1438diff --git a/go/vt/vtgate/buffer/shard_buffer.go b/go/vt/vtgate/buffer/shard_buffer.go
1439index 0916b225b..8a455b4f8 100644
1440--- a/go/vt/vtgate/buffer/shard_buffer.go
1441+++ b/go/vt/vtgate/buffer/shard_buffer.go
1442@@ -24,6 +24,7 @@ import (
1443
1444 "golang.org/x/net/context"
1445
1446+ "vitess.io/vitess/go/context2"
1447 "vitess.io/vitess/go/sync2"
1448 "vitess.io/vitess/go/vt/log"
1449 "vitess.io/vitess/go/vt/logutil"
1450@@ -327,7 +328,7 @@ func (sb *shardBuffer) bufferRequestLocked(ctx context.Context) (*entry, error)
1451 done: make(chan struct{}),
1452 deadline: sb.now().Add(*window),
1453 }
1454- e.bufferCtx, e.bufferCancel = context.WithCancel(ctx)
1455+ e.bufferCtx, e.bufferCancel = context2.WithCancel(ctx, "./go/vt/vtgate/buffer/shard_buffer.go:330")
1456 sb.queue = append(sb.queue, e)
1457
1458 if max := lastRequestsInFlightMax.Counts()[sb.statsKeyJoined]; max < int64(len(sb.queue)) {
1459diff --git a/go/vt/vtgate/endtoend/vstream_test.go b/go/vt/vtgate/endtoend/vstream_test.go
1460index 1d382bc0f..85e553346 100644
1461--- a/go/vt/vtgate/endtoend/vstream_test.go
1462+++ b/go/vt/vtgate/endtoend/vstream_test.go
1463@@ -22,6 +22,7 @@ import (
1464 "testing"
1465
1466 "github.com/golang/protobuf/proto"
1467+ "vitess.io/vitess/go/context2"
1468 "vitess.io/vitess/go/mysql"
1469 binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
1470 "vitess.io/vitess/go/vt/proto/query"
1471@@ -31,7 +32,7 @@ import (
1472 )
1473
1474 func TestVStream(t *testing.T) {
1475- ctx, cancel := context.WithCancel(context.Background())
1476+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/endtoend/vstream_test.go:34")
1477 defer cancel()
1478
1479 gconn, err := vtgateconn.Dial(ctx, grpcAddress)
1480diff --git a/go/vt/vtgate/engine/merge_sort.go b/go/vt/vtgate/engine/merge_sort.go
1481index ee5c9cf1d..1c87cad97 100644
1482--- a/go/vt/vtgate/engine/merge_sort.go
1483+++ b/go/vt/vtgate/engine/merge_sort.go
1484@@ -24,6 +24,7 @@ import (
1485
1486 "golang.org/x/net/context"
1487
1488+ "vitess.io/vitess/go/context2"
1489 "vitess.io/vitess/go/sqltypes"
1490
1491 querypb "vitess.io/vitess/go/vt/proto/query"
1492@@ -37,7 +38,7 @@ import (
1493 // was pulled out. Since the input streams are sorted the same way that the heap is
1494 // sorted, this guarantees that the merged stream will also be sorted the same way.
1495 func mergeSort(vcursor VCursor, query string, orderBy []OrderbyParams, rss []*srvtopo.ResolvedShard, bvs []map[string]*querypb.BindVariable, callback func(*sqltypes.Result) error) error {
1496- ctx, cancel := context.WithCancel(vcursor.Context())
1497+ ctx, cancel := context2.WithCancel(vcursor.Context(), "./go/vt/vtgate/engine/merge_sort.go:40")
1498 defer cancel()
1499
1500 handles := make([]*streamHandle, len(rss))
1501diff --git a/go/vt/vtgate/executor_stream_test.go b/go/vt/vtgate/executor_stream_test.go
1502index ea41aa88c..aabd41723 100644
1503--- a/go/vt/vtgate/executor_stream_test.go
1504+++ b/go/vt/vtgate/executor_stream_test.go
1505@@ -21,6 +21,7 @@ import (
1506 "time"
1507
1508 "golang.org/x/net/context"
1509+ "vitess.io/vitess/go/context2"
1510 "vitess.io/vitess/go/sqltypes"
1511 "vitess.io/vitess/go/vt/discovery"
1512 querypb "vitess.io/vitess/go/vt/proto/query"
1513@@ -85,7 +86,7 @@ func TestStreamSQLSharded(t *testing.T) {
1514
1515 func executorStreamMessages(executor *Executor, sql string) (qr *sqltypes.Result, err error) {
1516 results := make(chan *sqltypes.Result, 100)
1517- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
1518+ ctx, cancel := context2.WithTimeout(context.Background(), 10*time.Millisecond, "./go/vt/vtgate/executor_stream_test.go:88")
1519 defer cancel()
1520 err = executor.StreamExecute(
1521 ctx,
1522diff --git a/go/vt/vtgate/gateway/gateway.go b/go/vt/vtgate/gateway/gateway.go
1523index 7b458332f..a9c304969 100644
1524--- a/go/vt/vtgate/gateway/gateway.go
1525+++ b/go/vt/vtgate/gateway/gateway.go
1526@@ -23,6 +23,7 @@ import (
1527 "time"
1528
1529 "golang.org/x/net/context"
1530+ "vitess.io/vitess/go/context2"
1531 "vitess.io/vitess/go/flagutil"
1532 "vitess.io/vitess/go/vt/log"
1533
1534@@ -107,7 +108,7 @@ func GetCreator() Creator {
1535 // just calls it.
1536 func WaitForTablets(gw Gateway, tabletTypesToWait []topodatapb.TabletType) error {
1537 log.Infof("Gateway waiting for serving tablets...")
1538- ctx, cancel := context.WithTimeout(context.Background(), *initialTabletTimeout)
1539+ ctx, cancel := context2.WithTimeout(context.Background(), *initialTabletTimeout, "./go/vt/vtgate/gateway/gateway.go:110")
1540 defer cancel()
1541
1542 err := gw.WaitForTablets(ctx, tabletTypesToWait)
1543diff --git a/go/vt/vtgate/plugin_mysql_server.go b/go/vt/vtgate/plugin_mysql_server.go
1544index ea5e16abd..4cdd72c30 100644
1545--- a/go/vt/vtgate/plugin_mysql_server.go
1546+++ b/go/vt/vtgate/plugin_mysql_server.go
1547@@ -26,6 +26,7 @@ import (
1548 "syscall"
1549 "time"
1550
1551+ "vitess.io/vitess/go/context2"
1552 "vitess.io/vitess/go/vt/sqlparser"
1553 "vitess.io/vitess/go/vt/vterrors"
1554
1555@@ -89,7 +90,7 @@ func (vh *vtgateHandler) ConnectionClosed(c *mysql.Conn) {
1556 var ctx context.Context
1557 var cancel context.CancelFunc
1558 if *mysqlQueryTimeout != 0 {
1559- ctx, cancel = context.WithTimeout(context.Background(), *mysqlQueryTimeout)
1560+ ctx, cancel = context2.WithTimeout(context.Background(), *mysqlQueryTimeout, "./go/vt/vtgate/plugin_mysql_server.go:92")
1561 defer cancel()
1562 } else {
1563 ctx = context.Background()
1564@@ -136,7 +137,7 @@ func (vh *vtgateHandler) ComQuery(c *mysql.Conn, query string, callback func(*sq
1565 ctx := context.Background()
1566 var cancel context.CancelFunc
1567 if *mysqlQueryTimeout != 0 {
1568- ctx, cancel = context.WithTimeout(ctx, *mysqlQueryTimeout)
1569+ ctx, cancel = context2.WithTimeout(ctx, *mysqlQueryTimeout, "./go/vt/vtgate/plugin_mysql_server.go:139")
1570 defer cancel()
1571 }
1572
1573@@ -203,7 +204,7 @@ func (vh *vtgateHandler) ComPrepare(c *mysql.Conn, query string) ([]*querypb.Fie
1574 var ctx context.Context
1575 var cancel context.CancelFunc
1576 if *mysqlQueryTimeout != 0 {
1577- ctx, cancel = context.WithTimeout(context.Background(), *mysqlQueryTimeout)
1578+ ctx, cancel = context2.WithTimeout(context.Background(), *mysqlQueryTimeout, "./go/vt/vtgate/plugin_mysql_server.go:206")
1579 defer cancel()
1580 } else {
1581 ctx = context.Background()
1582@@ -262,7 +263,7 @@ func (vh *vtgateHandler) ComStmtExecute(c *mysql.Conn, prepare *mysql.PrepareDat
1583 var ctx context.Context
1584 var cancel context.CancelFunc
1585 if *mysqlQueryTimeout != 0 {
1586- ctx, cancel = context.WithTimeout(context.Background(), *mysqlQueryTimeout)
1587+ ctx, cancel = context2.WithTimeout(context.Background(), *mysqlQueryTimeout, "./go/vt/vtgate/plugin_mysql_server.go:265")
1588 defer cancel()
1589 } else {
1590 ctx = context.Background()
1591diff --git a/go/vt/vtgate/resolver.go b/go/vt/vtgate/resolver.go
1592index be535df38..813723054 100644
1593--- a/go/vt/vtgate/resolver.go
1594+++ b/go/vt/vtgate/resolver.go
1595@@ -26,6 +26,7 @@ import (
1596
1597 "github.com/golang/protobuf/proto"
1598 "golang.org/x/net/context"
1599+ "vitess.io/vitess/go/context2"
1600 "vitess.io/vitess/go/sqltypes"
1601 "vitess.io/vitess/go/vt/key"
1602 "vitess.io/vitess/go/vt/log"
1603@@ -347,7 +348,7 @@ func (res *Resolver) UpdateStream(ctx context.Context, keyspace string, shard st
1604 // VStream streams events from one target. This function ensures that events of each
1605 // transaction are streamed together, along with the corresponding GTID.
1606 func (res *Resolver) VStream(ctx context.Context, tabletType topodatapb.TabletType, vgtid *binlogdatapb.VGtid, filter *binlogdatapb.Filter, send func(events []*binlogdatapb.VEvent) error) error {
1607- ctx, cancel := context.WithCancel(ctx)
1608+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vtgate/resolver.go:350")
1609 defer cancel()
1610
1611 // mu protects sending on ch, err and positions.
1612diff --git a/go/vt/vtgate/resolver_test.go b/go/vt/vtgate/resolver_test.go
1613index e26a77e5e..67748fb38 100644
1614--- a/go/vt/vtgate/resolver_test.go
1615+++ b/go/vt/vtgate/resolver_test.go
1616@@ -27,6 +27,7 @@ import (
1617
1618 "github.com/golang/protobuf/proto"
1619 "golang.org/x/net/context"
1620+ "vitess.io/vitess/go/context2"
1621 "vitess.io/vitess/go/sqltypes"
1622 "vitess.io/vitess/go/vt/discovery"
1623 "vitess.io/vitess/go/vt/key"
1624@@ -570,7 +571,7 @@ func TestResolverVStream(t *testing.T) {
1625 }}
1626 sbc0.AddVStreamEvents(send2, nil)
1627
1628- ctx, cancel := context.WithCancel(context.Background())
1629+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/resolver_test.go:573")
1630 defer cancel()
1631
1632 count := 1
1633@@ -619,7 +620,7 @@ func TestResolverVStreamChunks(t *testing.T) {
1634 }
1635 sbc1.AddVStreamEvents([]*binlogdatapb.VEvent{{Type: binlogdatapb.VEventType_COMMIT}}, nil)
1636
1637- ctx, cancel := context.WithCancel(context.Background())
1638+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/resolver_test.go:622")
1639 defer cancel()
1640
1641 rowEncountered := false
1642@@ -695,7 +696,7 @@ func TestResolverVStreamMulti(t *testing.T) {
1643 }
1644 sbc1.AddVStreamEvents(send1, nil)
1645
1646- ctx, cancel := context.WithCancel(context.Background())
1647+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/resolver_test.go:698")
1648 defer cancel()
1649
1650 var got *binlogdatapb.VGtid
1651@@ -760,7 +761,7 @@ func TestResolverVStreamRetry(t *testing.T) {
1652 sbc0.AddVStreamEvents(nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "cc"))
1653 sbc0.AddVStreamEvents(nil, vterrors.Errorf(vtrpcpb.Code_FAILED_PRECONDITION, "final error"))
1654
1655- ctx, cancel := context.WithCancel(context.Background())
1656+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/resolver_test.go:763")
1657 defer cancel()
1658
1659 count := 0
1660@@ -819,7 +820,7 @@ func TestResolverVStreamHeartbeat(t *testing.T) {
1661 }}
1662 sbc0.AddVStreamEvents(send1, nil)
1663
1664- ctx, cancel := context.WithCancel(context.Background())
1665+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/resolver_test.go:822")
1666 defer cancel()
1667
1668 vgtid := &binlogdatapb.VGtid{
1669diff --git a/go/vt/vtgate/scatter_conn.go b/go/vt/vtgate/scatter_conn.go
1670index 3bc5cb796..fff03a706 100644
1671--- a/go/vt/vtgate/scatter_conn.go
1672+++ b/go/vt/vtgate/scatter_conn.go
1673@@ -25,6 +25,7 @@ import (
1674
1675 "golang.org/x/net/context"
1676
1677+ "vitess.io/vitess/go/context2"
1678 "vitess.io/vitess/go/sqltypes"
1679 "vitess.io/vitess/go/stats"
1680 "vitess.io/vitess/go/vt/concurrency"
1681@@ -546,7 +547,7 @@ func (tt *timeTracker) Record(target *querypb.Target) time.Time {
1682 func (stc *ScatterConn) MessageStream(ctx context.Context, rss []*srvtopo.ResolvedShard, name string, callback func(*sqltypes.Result) error) error {
1683 // The cancelable context is used for handling errors
1684 // from individual streams.
1685- ctx, cancel := context.WithCancel(ctx)
1686+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vtgate/scatter_conn.go:549")
1687 defer cancel()
1688
1689 // mu is used to merge multiple callback calls into one.
1690diff --git a/go/vt/vtgate/vcursor_impl.go b/go/vt/vtgate/vcursor_impl.go
1691index 8da8069b3..13dbec234 100644
1692--- a/go/vt/vtgate/vcursor_impl.go
1693+++ b/go/vt/vtgate/vcursor_impl.go
1694@@ -22,6 +22,7 @@ import (
1695
1696 "golang.org/x/net/context"
1697
1698+ "vitess.io/vitess/go/context2"
1699 "vitess.io/vitess/go/sqltypes"
1700 "vitess.io/vitess/go/vt/key"
1701 "vitess.io/vitess/go/vt/sqlparser"
1702@@ -82,7 +83,7 @@ func (vc *vcursorImpl) MaxMemoryRows() int {
1703
1704 // SetContextTimeout updates context and sets a timeout.
1705 func (vc *vcursorImpl) SetContextTimeout(timeout time.Duration) context.CancelFunc {
1706- ctx, cancel := context.WithTimeout(vc.ctx, timeout)
1707+ ctx, cancel := context2.WithTimeout(vc.ctx, timeout, "./go/vt/vtgate/vcursor_impl.go:85")
1708 vc.ctx = ctx
1709 return cancel
1710 }
1711diff --git a/go/vt/vtgate/vtgate_test.go b/go/vt/vtgate/vtgate_test.go
1712index 8a8093666..b90db46d0 100644
1713--- a/go/vt/vtgate/vtgate_test.go
1714+++ b/go/vt/vtgate/vtgate_test.go
1715@@ -29,6 +29,7 @@ import (
1716 "golang.org/x/net/context"
1717
1718 "github.com/golang/protobuf/proto"
1719+ "vitess.io/vitess/go/context2"
1720 "vitess.io/vitess/go/sqltypes"
1721 "vitess.io/vitess/go/vt/discovery"
1722 "vitess.io/vitess/go/vt/key"
1723@@ -1224,7 +1225,7 @@ func TestVTGateMessageStreamSharded(t *testing.T) {
1724 _ = hcVTGateTest.AddTestTablet("aa", "1.1.1.1", 1002, ks, "20-40", topodatapb.TabletType_MASTER, true, 1, nil)
1725 ch := make(chan *sqltypes.Result)
1726 done := make(chan struct{})
1727- ctx, cancel := context.WithCancel(context.Background())
1728+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/vtgate_test.go:1227")
1729 go func() {
1730 kr := &topodatapb.KeyRange{End: []byte{0x40}}
1731 err := rpcVTGate.MessageStream(ctx, ks, "", kr, "msg", func(qr *sqltypes.Result) error {
1732@@ -1269,7 +1270,7 @@ func TestVTGateMessageStreamUnsharded(t *testing.T) {
1733 _ = hcVTGateTest.AddTestTablet("aa", "1.1.1.1", 1001, ks, "0", topodatapb.TabletType_MASTER, true, 1, nil)
1734 ch := make(chan *sqltypes.Result)
1735 done := make(chan struct{})
1736- ctx, cancel := context.WithCancel(context.Background())
1737+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/vtgate_test.go:1272")
1738 go func() {
1739 err := rpcVTGate.MessageStream(ctx, ks, "0", nil, "msg", func(qr *sqltypes.Result) error {
1740 select {
1741@@ -1304,7 +1305,7 @@ func TestVTGateMessageStreamRetry(t *testing.T) {
1742 _ = hcVTGateTest.AddTestTablet("aa", "1.1.1.1", 1001, ks, "0", topodatapb.TabletType_MASTER, true, 1, nil)
1743 ch := make(chan *sqltypes.Result)
1744 done := make(chan struct{})
1745- ctx, cancel := context.WithCancel(context.Background())
1746+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/vtgate_test.go:1307")
1747 go func() {
1748 err := rpcVTGate.MessageStream(ctx, ks, "0", nil, "msg", func(qr *sqltypes.Result) error {
1749 select {
1750@@ -1347,7 +1348,7 @@ func TestVTGateMessageStreamUnavailable(t *testing.T) {
1751 tablet.MustFailCodes[vtrpcpb.Code_UNAVAILABLE] = 1
1752 ch := make(chan *sqltypes.Result)
1753 done := make(chan struct{})
1754- ctx, cancel := context.WithCancel(context.Background())
1755+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vtgate/vtgate_test.go:1350")
1756 go func() {
1757 err := rpcVTGate.MessageStream(ctx, ks, "0", nil, "msg", func(qr *sqltypes.Result) error {
1758 select {
1759diff --git a/go/vt/vtqueryserver/plugin_mysql_server.go b/go/vt/vtqueryserver/plugin_mysql_server.go
1760index a2593b95a..85fed96d8 100644
1761--- a/go/vt/vtqueryserver/plugin_mysql_server.go
1762+++ b/go/vt/vtqueryserver/plugin_mysql_server.go
1763@@ -25,6 +25,7 @@ import (
1764
1765 "golang.org/x/net/context"
1766
1767+ "vitess.io/vitess/go/context2"
1768 "vitess.io/vitess/go/mysql"
1769 "vitess.io/vitess/go/sqltypes"
1770 "vitess.io/vitess/go/vt/callerid"
1771@@ -75,7 +76,7 @@ func (mh *proxyHandler) ConnectionClosed(c *mysql.Conn) {
1772 var ctx context.Context
1773 var cancel context.CancelFunc
1774 if *mysqlQueryTimeout != 0 {
1775- ctx, cancel = context.WithTimeout(context.Background(), *mysqlQueryTimeout)
1776+ ctx, cancel = context2.WithTimeout(context.Background(), *mysqlQueryTimeout, "./go/vt/vtqueryserver/plugin_mysql_server.go:78")
1777 defer cancel()
1778 } else {
1779 ctx = context.Background()
1780@@ -90,7 +91,7 @@ func (mh *proxyHandler) ComQuery(c *mysql.Conn, query string, callback func(*sql
1781 var ctx context.Context
1782 var cancel context.CancelFunc
1783 if *mysqlQueryTimeout != 0 {
1784- ctx, cancel = context.WithTimeout(context.Background(), *mysqlQueryTimeout)
1785+ ctx, cancel = context2.WithTimeout(context.Background(), *mysqlQueryTimeout, "./go/vt/vtqueryserver/plugin_mysql_server.go:93")
1786 defer cancel()
1787 } else {
1788 ctx = context.Background()
1789diff --git a/go/vt/vttablet/agentrpctest/test_agent_rpc.go b/go/vt/vttablet/agentrpctest/test_agent_rpc.go
1790index 5632b66ae..44d6d5ac8 100644
1791--- a/go/vt/vttablet/agentrpctest/test_agent_rpc.go
1792+++ b/go/vt/vttablet/agentrpctest/test_agent_rpc.go
1793@@ -28,6 +28,7 @@ import (
1794 "golang.org/x/net/context"
1795
1796 "github.com/golang/protobuf/proto"
1797+ "vitess.io/vitess/go/context2"
1798 "vitess.io/vitess/go/sqltypes"
1799 "vitess.io/vitess/go/vt/hook"
1800 "vitess.io/vitess/go/vt/logutil"
1801@@ -201,7 +202,7 @@ func agentRPCTestPingPanic(ctx context.Context, t *testing.T, client tmclient.Ta
1802 // RPCs failed due to an expired context before .Dial().
1803 func agentRPCTestDialExpiredContext(ctx context.Context, t *testing.T, client tmclient.TabletManagerClient, tablet *topodatapb.Tablet) {
1804 // Using a timeout of 0 here such that .Dial() will fail immediately.
1805- expiredCtx, cancel := context.WithTimeout(ctx, 0)
1806+ expiredCtx, cancel := context2.WithTimeout(ctx, 0, "./go/vt/vttablet/agentrpctest/test_agent_rpc.go:204")
1807 defer cancel()
1808 err := client.Ping(expiredCtx, tablet)
1809 if err == nil {
1810@@ -227,7 +228,7 @@ func agentRPCTestRPCTimeout(ctx context.Context, t *testing.T, client tmclient.T
1811 // NOTE: This might still race e.g. when test execution takes too long the
1812 // context will be expired in dial() already. In such cases coverage
1813 // will be reduced but the test will not flake.
1814- shortCtx, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
1815+ shortCtx, cancel := context2.WithTimeout(ctx, 10*time.Millisecond, "./go/vt/vttablet/agentrpctest/test_agent_rpc.go:230")
1816 defer cancel()
1817 fakeAgent.setSlow(true)
1818 defer func() { fakeAgent.setSlow(false) }()
1819diff --git a/go/vt/vttablet/endtoend/misc_test.go b/go/vt/vttablet/endtoend/misc_test.go
1820index 39af7ba16..eb2a8738d 100644
1821--- a/go/vt/vttablet/endtoend/misc_test.go
1822+++ b/go/vt/vttablet/endtoend/misc_test.go
1823@@ -29,6 +29,7 @@ import (
1824
1825 "github.com/golang/protobuf/proto"
1826 "golang.org/x/net/context"
1827+ "vitess.io/vitess/go/context2"
1828 "vitess.io/vitess/go/mysql"
1829 "vitess.io/vitess/go/sqltypes"
1830 "vitess.io/vitess/go/vt/callerid"
1831@@ -467,7 +468,7 @@ func TestStreamHealth_Expired(t *testing.T) {
1832 var health *querypb.StreamHealthResponse
1833 framework.Server.BroadcastHealth(0, nil, time.Millisecond)
1834 time.Sleep(5 * time.Millisecond)
1835- ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*100)
1836+ ctx, cancel := context2.WithTimeout(context.Background(), time.Millisecond*100, "./go/vt/vttablet/endtoend/misc_test.go:470")
1837 defer cancel()
1838 if err := framework.Server.StreamHealth(ctx, func(shr *querypb.StreamHealthResponse) error {
1839 health = shr
1840diff --git a/go/vt/vttablet/grpctabletconn/conn.go b/go/vt/vttablet/grpctabletconn/conn.go
1841index aae4da11a..1ef34b9c1 100644
1842--- a/go/vt/vttablet/grpctabletconn/conn.go
1843+++ b/go/vt/vttablet/grpctabletconn/conn.go
1844@@ -23,6 +23,7 @@ import (
1845
1846 "golang.org/x/net/context"
1847 "google.golang.org/grpc"
1848+ "vitess.io/vitess/go/context2"
1849 "vitess.io/vitess/go/netutil"
1850 "vitess.io/vitess/go/sqltypes"
1851 "vitess.io/vitess/go/vt/callerid"
1852@@ -148,7 +149,7 @@ func (conn *gRPCQueryClient) StreamExecute(ctx context.Context, target *querypb.
1853 // no direct API to end a stream from the client side. If callback
1854 // returns an error, we return from the function. The deferred
1855 // cancel will then cause the stream to be terminated.
1856- ctx, cancel := context.WithCancel(ctx)
1857+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/grpctabletconn/conn.go:151")
1858 defer cancel()
1859
1860 stream, err := func() (queryservicepb.Query_StreamExecuteClient, error) {
1861@@ -493,7 +494,7 @@ func (conn *gRPCQueryClient) BeginExecuteBatch(ctx context.Context, target *quer
1862 // MessageStream streams messages.
1863 func (conn *gRPCQueryClient) MessageStream(ctx context.Context, target *querypb.Target, name string, callback func(*sqltypes.Result) error) error {
1864 // Please see comments in StreamExecute to see how this works.
1865- ctx, cancel := context.WithCancel(ctx)
1866+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/grpctabletconn/conn.go:496")
1867 defer cancel()
1868
1869 stream, err := func() (queryservicepb.Query_MessageStreamClient, error) {
1870@@ -594,7 +595,7 @@ func (conn *gRPCQueryClient) SplitQuery(
1871 // StreamHealth starts a streaming RPC for VTTablet health status updates.
1872 func (conn *gRPCQueryClient) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error {
1873 // Please see comments in StreamExecute to see how this works.
1874- ctx, cancel := context.WithCancel(ctx)
1875+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/grpctabletconn/conn.go:597")
1876 defer cancel()
1877
1878 stream, err := func() (queryservicepb.Query_StreamHealthClient, error) {
1879@@ -630,7 +631,7 @@ func (conn *gRPCQueryClient) StreamHealth(ctx context.Context, callback func(*qu
1880 // UpdateStream starts a streaming query to VTTablet.
1881 func (conn *gRPCQueryClient) UpdateStream(ctx context.Context, target *querypb.Target, position string, timestamp int64, callback func(*querypb.StreamEvent) error) error {
1882 // Please see comments in StreamExecute to see how this works.
1883- ctx, cancel := context.WithCancel(ctx)
1884+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/grpctabletconn/conn.go:633")
1885 defer cancel()
1886
1887 stream, err := func() (queryservicepb.Query_UpdateStreamClient, error) {
1888diff --git a/go/vt/vttablet/heartbeat/reader.go b/go/vt/vttablet/heartbeat/reader.go
1889index 54dbc72b8..b66774860 100644
1890--- a/go/vt/vttablet/heartbeat/reader.go
1891+++ b/go/vt/vttablet/heartbeat/reader.go
1892@@ -21,6 +21,7 @@ import (
1893 "sync"
1894 "time"
1895
1896+ "vitess.io/vitess/go/context2"
1897 "vitess.io/vitess/go/vt/vterrors"
1898
1899 "golang.org/x/net/context"
1900@@ -149,7 +150,7 @@ func (r *Reader) GetLatest() (time.Duration, error) {
1901 func (r *Reader) readHeartbeat() {
1902 defer tabletenv.LogError()
1903
1904- ctx, cancel := context.WithDeadline(context.Background(), r.now().Add(r.interval))
1905+ ctx, cancel := context2.WithDeadline(context.Background(), r.now().Add(r.interval), "./go/vt/vttablet/heartbeat/reader.go:152")
1906 defer cancel()
1907
1908 res, err := r.fetchMostRecentHeartbeat(ctx)
1909diff --git a/go/vt/vttablet/heartbeat/writer.go b/go/vt/vttablet/heartbeat/writer.go
1910index e84f75920..da9ee67b7 100644
1911--- a/go/vt/vttablet/heartbeat/writer.go
1912+++ b/go/vt/vttablet/heartbeat/writer.go
1913@@ -21,6 +21,7 @@ import (
1914 "sync"
1915 "time"
1916
1917+ "vitess.io/vitess/go/context2"
1918 "vitess.io/vitess/go/vt/vterrors"
1919
1920 "golang.org/x/net/context"
1921@@ -203,7 +204,7 @@ func (w *Writer) bindHeartbeatVars(query string) (string, error) {
1922 // writeHeartbeat updates the heartbeat row for this tablet with the current time in nanoseconds.
1923 func (w *Writer) writeHeartbeat() {
1924 defer tabletenv.LogError()
1925- ctx, cancel := context.WithDeadline(context.Background(), w.now().Add(w.interval))
1926+ ctx, cancel := context2.WithDeadline(context.Background(), w.now().Add(w.interval), "./go/vt/vttablet/heartbeat/writer.go:206")
1927 defer cancel()
1928 update, err := w.bindHeartbeatVars(sqlUpdateHeartbeat)
1929 if err != nil {
1930diff --git a/go/vt/vttablet/tabletmanager/action_agent.go b/go/vt/vttablet/tabletmanager/action_agent.go
1931index 7fe05a7b5..fe01c4d4a 100644
1932--- a/go/vt/vttablet/tabletmanager/action_agent.go
1933+++ b/go/vt/vttablet/tabletmanager/action_agent.go
1934@@ -44,6 +44,7 @@ import (
1935 "sync"
1936 "time"
1937
1938+ "vitess.io/vitess/go/context2"
1939 "vitess.io/vitess/go/vt/vterrors"
1940
1941 "golang.org/x/net/context"
1942@@ -746,7 +747,7 @@ func (agent *ActionAgent) checkTabletMysqlPort(ctx context.Context, tablet *topo
1943 // Update the port in the topology. Use a shorter timeout, so if
1944 // the topo server is busy / throttling us, we don't hang forever here.
1945 // The healthcheck go routine will try again next time.
1946- ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
1947+ ctx, cancel := context2.WithTimeout(ctx, 10*time.Second, "./go/vt/vttablet/tabletmanager/action_agent.go:749")
1948 defer cancel()
1949 if !agent.waitingForMysql {
1950 log.Warningf("MySQL port has changed from %v to %v, updating it in tablet record", topoproto.MysqlPort(tablet), mport)
1951diff --git a/go/vt/vttablet/tabletmanager/init_tablet.go b/go/vt/vttablet/tabletmanager/init_tablet.go
1952index 47e5c0091..a731a13e0 100644
1953--- a/go/vt/vttablet/tabletmanager/init_tablet.go
1954+++ b/go/vt/vttablet/tabletmanager/init_tablet.go
1955@@ -24,8 +24,7 @@ import (
1956 "fmt"
1957 "time"
1958
1959- "golang.org/x/net/context"
1960-
1961+ "vitess.io/vitess/go/context2"
1962 "vitess.io/vitess/go/flagutil"
1963 "vitess.io/vitess/go/netutil"
1964 "vitess.io/vitess/go/vt/log"
1965@@ -84,7 +83,7 @@ func (agent *ActionAgent) InitTablet(port, gRPCPort int32) error {
1966
1967 // Create a context for this whole operation. Note we will
1968 // retry some actions upon failure up to this context expires.
1969- ctx, cancel := context.WithTimeout(agent.batchCtx, *initTimeout)
1970+ ctx, cancel := context2.WithTimeout(agent.batchCtx, *initTimeout, "./go/vt/vttablet/tabletmanager/init_tablet.go:87")
1971 defer cancel()
1972
1973 // Read the shard, create it if necessary.
1974diff --git a/go/vt/vttablet/tabletmanager/replication_reporter.go b/go/vt/vttablet/tabletmanager/replication_reporter.go
1975index 4ec3b1241..5f3ca9ecf 100644
1976--- a/go/vt/vttablet/tabletmanager/replication_reporter.go
1977+++ b/go/vt/vttablet/tabletmanager/replication_reporter.go
1978@@ -22,6 +22,7 @@ import (
1979 "html/template"
1980 "time"
1981
1982+ "vitess.io/vitess/go/context2"
1983 "vitess.io/vitess/go/vt/vterrors"
1984
1985 "golang.org/x/net/context"
1986@@ -68,7 +69,7 @@ func (r *replicationReporter) Report(isSlaveType, shouldQueryServiceBeRunning bo
1987 log.Infof("Slave is stopped. Running with --disable_active_reparents so will not try to reconnect to master...")
1988 } else {
1989 log.Infof("Slave is stopped. Trying to reconnect to master...")
1990- ctx, cancel := context.WithTimeout(r.agent.batchCtx, 5*time.Second)
1991+ ctx, cancel := context2.WithTimeout(r.agent.batchCtx, 5*time.Second, "./go/vt/vttablet/tabletmanager/replication_reporter.go:71")
1992 if err := repairReplication(ctx, r.agent); err != nil {
1993 log.Infof("Failed to reconnect to master: %v", err)
1994 }
1995diff --git a/go/vt/vttablet/tabletmanager/rpc_external_reparent.go b/go/vt/vttablet/tabletmanager/rpc_external_reparent.go
1996index 7b066ed1e..c389dfe3b 100644
1997--- a/go/vt/vttablet/tabletmanager/rpc_external_reparent.go
1998+++ b/go/vt/vttablet/tabletmanager/rpc_external_reparent.go
1999@@ -23,6 +23,7 @@ import (
2000
2001 "github.com/golang/protobuf/proto"
2002 "golang.org/x/net/context"
2003+ "vitess.io/vitess/go/context2"
2004 "vitess.io/vitess/go/event"
2005 "vitess.io/vitess/go/stats"
2006 "vitess.io/vitess/go/trace"
2007@@ -116,7 +117,7 @@ func (agent *ActionAgent) TabletExternallyReparented(ctx context.Context, extern
2008 agent.updateState(ctx, newTablet, "fastTabletExternallyReparented")
2009
2010 // Start the finalize stage with a background context, but connect the trace.
2011- bgCtx, cancel := context.WithTimeout(agent.batchCtx, *finalizeReparentTimeout)
2012+ bgCtx, cancel := context2.WithTimeout(agent.batchCtx, *finalizeReparentTimeout, "./go/vt/vttablet/tabletmanager/rpc_external_reparent.go:119")
2013 bgCtx = trace.CopySpan(bgCtx, ctx)
2014 agent.finalizeReparentCtx = bgCtx
2015 go func() {
2016diff --git a/go/vt/vttablet/tabletmanager/rpc_replication.go b/go/vt/vttablet/tabletmanager/rpc_replication.go
2017index 9ef143979..850fb57ee 100644
2018--- a/go/vt/vttablet/tabletmanager/rpc_replication.go
2019+++ b/go/vt/vttablet/tabletmanager/rpc_replication.go
2020@@ -21,6 +21,7 @@ import (
2021 "fmt"
2022 "time"
2023
2024+ "vitess.io/vitess/go/context2"
2025 "vitess.io/vitess/go/vt/vterrors"
2026
2027 "golang.org/x/net/context"
2028@@ -103,7 +104,7 @@ func (agent *ActionAgent) StopSlaveMinimum(ctx context.Context, position string,
2029 if err != nil {
2030 return "", err
2031 }
2032- waitCtx, cancel := context.WithTimeout(ctx, waitTime)
2033+ waitCtx, cancel := context2.WithTimeout(ctx, waitTime, "./go/vt/vttablet/tabletmanager/rpc_replication.go:106")
2034 defer cancel()
2035 if err := agent.MysqlDaemon.WaitMasterPos(waitCtx, pos); err != nil {
2036 return "", err
2037@@ -153,7 +154,7 @@ func (agent *ActionAgent) StartSlaveUntilAfter(ctx context.Context, position str
2038 }
2039 defer agent.unlock()
2040
2041- waitCtx, cancel := context.WithTimeout(ctx, waitTime)
2042+ waitCtx, cancel := context2.WithTimeout(ctx, waitTime, "./go/vt/vttablet/tabletmanager/rpc_replication.go:156")
2043 defer cancel()
2044
2045 pos, err := mysql.DecodePosition(position)
2046diff --git a/go/vt/vttablet/tabletmanager/vreplication/controller.go b/go/vt/vttablet/tabletmanager/vreplication/controller.go
2047index 41c333aa9..dc8ee78eb 100644
2048--- a/go/vt/vttablet/tabletmanager/vreplication/controller.go
2049+++ b/go/vt/vttablet/tabletmanager/vreplication/controller.go
2050@@ -22,6 +22,7 @@ import (
2051 "strconv"
2052 "time"
2053
2054+ "vitess.io/vitess/go/context2"
2055 "vitess.io/vitess/go/vt/vterrors"
2056
2057 "github.com/golang/protobuf/proto"
2058@@ -106,7 +107,7 @@ func newController(ctx context.Context, params map[string]string, dbClientFactor
2059 ct.tabletPicker = tp
2060
2061 // cancel
2062- ctx, ct.cancel = context.WithCancel(ctx)
2063+ ctx, ct.cancel = context2.WithCancel(ctx, "./go/vt/vttablet/tabletmanager/vreplication/controller.go:109")
2064
2065 go ct.run(ctx)
2066
2067diff --git a/go/vt/vttablet/tabletmanager/vreplication/controller_test.go b/go/vt/vttablet/tabletmanager/vreplication/controller_test.go
2068index ba858cf04..630732948 100644
2069--- a/go/vt/vttablet/tabletmanager/vreplication/controller_test.go
2070+++ b/go/vt/vttablet/tabletmanager/vreplication/controller_test.go
2071@@ -24,6 +24,7 @@ import (
2072
2073 "golang.org/x/net/context"
2074
2075+ "vitess.io/vitess/go/context2"
2076 "vitess.io/vitess/go/sqltypes"
2077 "vitess.io/vitess/go/vt/binlog/binlogplayer"
2078 "vitess.io/vitess/go/vt/mysqlctl/fakemysqldaemon"
2079@@ -223,7 +224,7 @@ func TestControllerCanceledContext(t *testing.T) {
2080 "source": fmt.Sprintf(`keyspace:"%s" shard:"0" key_range:<end:"\200" > `, env.KeyspaceName),
2081 }
2082
2083- ctx, cancel := context.WithCancel(context.Background())
2084+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletmanager/vreplication/controller_test.go:226")
2085 cancel()
2086 ct, err := newController(ctx, params, nil, nil, env.TopoServ, env.Cells[0], "rdonly", nil)
2087 if err != nil {
2088diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine.go b/go/vt/vttablet/tabletmanager/vreplication/engine.go
2089index 9a08a9746..618deca59 100644
2090--- a/go/vt/vttablet/tabletmanager/vreplication/engine.go
2091+++ b/go/vt/vttablet/tabletmanager/vreplication/engine.go
2092@@ -24,6 +24,7 @@ import (
2093 "time"
2094
2095 "golang.org/x/net/context"
2096+ "vitess.io/vitess/go/context2"
2097 "vitess.io/vitess/go/mysql"
2098 "vitess.io/vitess/go/sqltypes"
2099 "vitess.io/vitess/go/vt/binlog/binlogplayer"
2100@@ -109,7 +110,7 @@ func (vre *Engine) Open(ctx context.Context) error {
2101 return nil
2102 }
2103
2104- vre.ctx, vre.cancel = context.WithCancel(ctx)
2105+ vre.ctx, vre.cancel = context2.WithCancel(ctx, "./go/vt/vttablet/tabletmanager/vreplication/engine.go:112")
2106 vre.isOpen = true
2107 if err := vre.initAll(); err != nil {
2108 go vre.Close()
2109diff --git a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go
2110index 27f2d31d6..f3de8a862 100644
2111--- a/go/vt/vttablet/tabletmanager/vreplication/engine_test.go
2112+++ b/go/vt/vttablet/tabletmanager/vreplication/engine_test.go
2113@@ -23,6 +23,7 @@ import (
2114 "time"
2115
2116 "golang.org/x/net/context"
2117+ "vitess.io/vitess/go/context2"
2118 "vitess.io/vitess/go/mysql"
2119 "vitess.io/vitess/go/sqltypes"
2120 "vitess.io/vitess/go/vt/binlog/binlogplayer"
2121@@ -364,7 +365,7 @@ func TestWaitForPosCancel(t *testing.T) {
2122 sqltypes.NewVarBinary("Running"),
2123 sqltypes.NewVarBinary(""),
2124 }}}, nil)
2125- ctx, cancel := context.WithCancel(context.Background())
2126+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletmanager/vreplication/engine_test.go:367")
2127 cancel()
2128 err := vre.WaitForPos(ctx, 1, "MariaDB/0-1-1084")
2129 if err == nil || err != context.Canceled {
2130diff --git a/go/vt/vttablet/tabletmanager/vreplication/vcopier.go b/go/vt/vttablet/tabletmanager/vreplication/vcopier.go
2131index 37152f006..83ebb5bd6 100644
2132--- a/go/vt/vttablet/tabletmanager/vreplication/vcopier.go
2133+++ b/go/vt/vttablet/tabletmanager/vreplication/vcopier.go
2134@@ -27,6 +27,7 @@ import (
2135 "github.com/golang/protobuf/proto"
2136 "golang.org/x/net/context"
2137
2138+ "vitess.io/vitess/go/context2"
2139 "vitess.io/vitess/go/mysql"
2140 "vitess.io/vitess/go/sqltypes"
2141 "vitess.io/vitess/go/vt/binlog/binlogplayer"
2142@@ -115,7 +116,7 @@ func (vc *vcopier) copyNext(ctx context.Context, settings binlogplayer.VRSetting
2143 }
2144
2145 func (vc *vcopier) catchup(ctx context.Context, copyState map[string]*sqltypes.Result) error {
2146- ctx, cancel := context.WithCancel(ctx)
2147+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/tabletmanager/vreplication/vcopier.go:118")
2148 defer cancel()
2149
2150 settings, err := binlogplayer.ReadVRSettings(vc.vr.dbClient, vc.vr.id)
2151@@ -182,7 +183,7 @@ func (vc *vcopier) copyTable(ctx context.Context, tableName string, copyState ma
2152 }
2153 defer vsClient.Close(ctx)
2154
2155- ctx, cancel := context.WithTimeout(ctx, copyTimeout)
2156+ ctx, cancel := context2.WithTimeout(ctx, copyTimeout, "./go/vt/vttablet/tabletmanager/vreplication/vcopier.go:185")
2157 defer cancel()
2158
2159 target := &querypb.Target{
2160diff --git a/go/vt/vttablet/tabletmanager/vreplication/vplayer.go b/go/vt/vttablet/tabletmanager/vreplication/vplayer.go
2161index 3a4bfd1ff..8681eccf8 100644
2162--- a/go/vt/vttablet/tabletmanager/vreplication/vplayer.go
2163+++ b/go/vt/vttablet/tabletmanager/vreplication/vplayer.go
2164@@ -24,6 +24,7 @@ import (
2165 "time"
2166
2167 "golang.org/x/net/context"
2168+ "vitess.io/vitess/go/context2"
2169 "vitess.io/vitess/go/mysql"
2170 "vitess.io/vitess/go/sqltypes"
2171
2172@@ -113,7 +114,7 @@ func (vp *vplayer) fetchAndApply(ctx context.Context) error {
2173 return fmt.Errorf("error dialing tablet: %v", err)
2174 }
2175 defer vsClient.Close(ctx)
2176- ctx, cancel := context.WithCancel(ctx)
2177+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/tabletmanager/vreplication/vplayer.go:116")
2178 defer cancel()
2179
2180 relay := newRelayLog(ctx, relayLogMaxItems, relayLogMaxSize)
2181diff --git a/go/vt/vttablet/tabletserver/connpool/dbconn_test.go b/go/vt/vttablet/tabletserver/connpool/dbconn_test.go
2182index aad986ee7..855a5622f 100644
2183--- a/go/vt/vttablet/tabletserver/connpool/dbconn_test.go
2184+++ b/go/vt/vttablet/tabletserver/connpool/dbconn_test.go
2185@@ -26,6 +26,7 @@ import (
2186
2187 "golang.org/x/net/context"
2188
2189+ "vitess.io/vitess/go/context2"
2190 "vitess.io/vitess/go/mysql"
2191 "vitess.io/vitess/go/mysql/fakesqldb"
2192 "vitess.io/vitess/go/sqltypes"
2193@@ -62,7 +63,7 @@ func TestDBConnExec(t *testing.T) {
2194 connPool := newPool()
2195 connPool.Open(db.ConnParams(), db.ConnParams(), db.ConnParams())
2196 defer connPool.Close()
2197- ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(10*time.Second))
2198+ ctx, cancel := context2.WithDeadline(context.Background(), time.Now().Add(10*time.Second), "./go/vt/vttablet/tabletserver/connpool/dbconn_test.go:65")
2199 defer cancel()
2200 dbConn, err := NewDBConn(connPool, db.ConnParams())
2201 if dbConn != nil {
2202@@ -140,7 +141,7 @@ func TestDBConnDeadline(t *testing.T) {
2203 defer connPool.Close()
2204
2205 db.SetConnDelay(100 * time.Millisecond)
2206- ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(50*time.Millisecond))
2207+ ctx, cancel := context2.WithDeadline(context.Background(), time.Now().Add(50*time.Millisecond), "./go/vt/vttablet/tabletserver/connpool/dbconn_test.go:143")
2208 defer cancel()
2209
2210 dbConn, err := NewDBConn(connPool, db.ConnParams())
2211@@ -163,7 +164,7 @@ func TestDBConnDeadline(t *testing.T) {
2212
2213 startCounts = tabletenv.MySQLStats.Counts()
2214
2215- ctx, cancel = context.WithDeadline(context.Background(), time.Now().Add(10*time.Second))
2216+ ctx, cancel = context2.WithDeadline(context.Background(), time.Now().Add(10*time.Second), "./go/vt/vttablet/tabletserver/connpool/dbconn_test.go:166")
2217 defer cancel()
2218
2219 result, err := dbConn.Exec(ctx, sql, 1, false)
2220@@ -300,7 +301,7 @@ func TestDBConnStream(t *testing.T) {
2221 connPool := newPool()
2222 connPool.Open(db.ConnParams(), db.ConnParams(), db.ConnParams())
2223 defer connPool.Close()
2224- ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(10*time.Second))
2225+ ctx, cancel := context2.WithDeadline(context.Background(), time.Now().Add(10*time.Second), "./go/vt/vttablet/tabletserver/connpool/dbconn_test.go:303")
2226 defer cancel()
2227 dbConn, err := NewDBConn(connPool, db.ConnParams())
2228 if dbConn != nil {
2229diff --git a/go/vt/vttablet/tabletserver/messager/message_manager.go b/go/vt/vttablet/tabletserver/messager/message_manager.go
2230index 2b8b93e4d..a8aadf356 100644
2231--- a/go/vt/vttablet/tabletserver/messager/message_manager.go
2232+++ b/go/vt/vttablet/tabletserver/messager/message_manager.go
2233@@ -23,6 +23,7 @@ import (
2234
2235 "golang.org/x/net/context"
2236
2237+ "vitess.io/vitess/go/context2"
2238 "vitess.io/vitess/go/sqltypes"
2239 "vitess.io/vitess/go/stats"
2240 "vitess.io/vitess/go/sync2"
2241@@ -56,7 +57,7 @@ type messageReceiver struct {
2242 }
2243
2244 func newMessageReceiver(ctx context.Context, send func(*sqltypes.Result) error) (*messageReceiver, <-chan struct{}) {
2245- ctx, cancel := context.WithCancel(ctx)
2246+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/tabletserver/messager/message_manager.go:59")
2247 rcv := &messageReceiver{
2248 ctx: ctx,
2249 errChan: make(chan error, 1),
2250@@ -533,7 +534,7 @@ func (mm *messageManager) postpone(tsv TabletService, name string, ackWaitTime t
2251 return
2252 }
2253 defer mm.postponeSema.Release()
2254- ctx, cancel := context.WithTimeout(tabletenv.LocalContext(), ackWaitTime)
2255+ ctx, cancel := context2.WithTimeout(tabletenv.LocalContext(), ackWaitTime, "./go/vt/vttablet/tabletserver/messager/message_manager.go:536")
2256 defer cancel()
2257 if _, err := tsv.PostponeMessages(ctx, nil, name, ids); err != nil {
2258 // This can happen during spikes. Record the incident for monitoring.
2259@@ -542,7 +543,7 @@ func (mm *messageManager) postpone(tsv TabletService, name string, ackWaitTime t
2260 }
2261
2262 func (mm *messageManager) runPoller() {
2263- ctx, cancel := context.WithTimeout(tabletenv.LocalContext(), mm.pollerTicks.Interval())
2264+ ctx, cancel := context2.WithTimeout(tabletenv.LocalContext(), mm.pollerTicks.Interval(), "./go/vt/vttablet/tabletserver/messager/message_manager.go:545")
2265 defer func() {
2266 tabletenv.LogError()
2267 cancel()
2268@@ -612,7 +613,7 @@ func (mm *messageManager) runPurge() {
2269 // purge is a non-member because it should be called asynchronously and should
2270 // not rely on members of messageManager.
2271 func purge(tsv TabletService, name string, purgeAfter, purgeInterval time.Duration) {
2272- ctx, cancel := context.WithTimeout(tabletenv.LocalContext(), purgeInterval)
2273+ ctx, cancel := context2.WithTimeout(tabletenv.LocalContext(), purgeInterval, "./go/vt/vttablet/tabletserver/messager/message_manager.go:615")
2274 defer func() {
2275 tabletenv.LogError()
2276 cancel()
2277diff --git a/go/vt/vttablet/tabletserver/messager/message_manager_test.go b/go/vt/vttablet/tabletserver/messager/message_manager_test.go
2278index aa43af69e..6fd142db7 100644
2279--- a/go/vt/vttablet/tabletserver/messager/message_manager_test.go
2280+++ b/go/vt/vttablet/tabletserver/messager/message_manager_test.go
2281@@ -26,6 +26,7 @@ import (
2282
2283 "golang.org/x/net/context"
2284
2285+ "vitess.io/vitess/go/context2"
2286 "vitess.io/vitess/go/mysql/fakesqldb"
2287 "vitess.io/vitess/go/sqltypes"
2288 "vitess.io/vitess/go/sync2"
2289@@ -106,7 +107,7 @@ func TestReceiverCancel(t *testing.T) {
2290 mm.Open()
2291 defer mm.Close()
2292 r1 := newTestReceiver(0)
2293- ctx, cancel := context.WithCancel(context.Background())
2294+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/messager/message_manager_test.go:109")
2295 _ = mm.Subscribe(ctx, r1.rcv)
2296 cancel()
2297 // r1 should eventually be unsubscribed.
2298@@ -232,7 +233,7 @@ func TestMessageManagerSend(t *testing.T) {
2299
2300 // Test that mm stops sending to a canceled receiver.
2301 r2 := newTestReceiver(1)
2302- ctx, cancel := context.WithCancel(context.Background())
2303+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/messager/message_manager_test.go:235")
2304 mm.Subscribe(ctx, r2.rcv)
2305 <-r2.ch
2306 mm.Add(&MessageRow{Row: []sqltypes.Value{sqltypes.NewVarBinary("2")}})
2307@@ -343,7 +344,7 @@ func TestMessageManagerSendEOF(t *testing.T) {
2308 mm.Open()
2309 defer mm.Close()
2310 r1 := newTestReceiver(0)
2311- ctx, cancel := context.WithCancel(context.Background())
2312+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/messager/message_manager_test.go:346")
2313 mm.Subscribe(ctx, r1.rcv)
2314 // Pull field info.
2315 <-r1.ch
2316@@ -514,7 +515,7 @@ func TestMessageManagerPoller(t *testing.T) {
2317 mm.Open()
2318 defer mm.Close()
2319 r1 := newTestReceiver(1)
2320- ctx, cancel := context.WithCancel(context.Background())
2321+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/messager/message_manager_test.go:517")
2322 mm.Subscribe(ctx, r1.rcv)
2323 <-r1.ch
2324 mm.pollerTicks.Trigger()
2325diff --git a/go/vt/vttablet/tabletserver/query_engine.go b/go/vt/vttablet/tabletserver/query_engine.go
2326index f2994f784..c7eb0e64e 100644
2327--- a/go/vt/vttablet/tabletserver/query_engine.go
2328+++ b/go/vt/vttablet/tabletserver/query_engine.go
2329@@ -28,6 +28,7 @@ import (
2330
2331 "vitess.io/vitess/go/acl"
2332 "vitess.io/vitess/go/cache"
2333+ "vitess.io/vitess/go/context2"
2334 "vitess.io/vitess/go/mysql"
2335 "vitess.io/vitess/go/stats"
2336 "vitess.io/vitess/go/streamlog"
2337@@ -383,7 +384,7 @@ func (qe *QueryEngine) getQueryConn(ctx context.Context) (*connpool.DBConn, erro
2338
2339 timeout := qe.connTimeout.Get()
2340 if timeout != 0 {
2341- ctxTimeout, cancel := context.WithTimeout(ctx, timeout)
2342+ ctxTimeout, cancel := context2.WithTimeout(ctx, timeout, "./go/vt/vttablet/tabletserver/query_engine.go:386")
2343 defer cancel()
2344 conn, err := qe.conns.Get(ctxTimeout)
2345 if err != nil {
2346diff --git a/go/vt/vttablet/tabletserver/replication_watcher.go b/go/vt/vttablet/tabletserver/replication_watcher.go
2347index da3bfd9df..615ce96ee 100644
2348--- a/go/vt/vttablet/tabletserver/replication_watcher.go
2349+++ b/go/vt/vttablet/tabletserver/replication_watcher.go
2350@@ -22,6 +22,7 @@ import (
2351
2352 "golang.org/x/net/context"
2353
2354+ "vitess.io/vitess/go/context2"
2355 "vitess.io/vitess/go/mysql"
2356 "vitess.io/vitess/go/stats"
2357 "vitess.io/vitess/go/vt/binlog"
2358@@ -91,7 +92,7 @@ func (rpw *ReplicationWatcher) Open() {
2359 if rpw.isOpen || !rpw.watchReplication {
2360 return
2361 }
2362- ctx, cancel := context.WithCancel(tabletenv.LocalContext())
2363+ ctx, cancel := context2.WithCancel(tabletenv.LocalContext(), "./go/vt/vttablet/tabletserver/replication_watcher.go:94")
2364 rpw.cancel = cancel
2365 rpw.wg.Add(1)
2366 go rpw.Process(ctx, rpw.dbconfigs)
2367diff --git a/go/vt/vttablet/tabletserver/tabletserver.go b/go/vt/vttablet/tabletserver/tabletserver.go
2368index 64711af9b..89393bd19 100644
2369--- a/go/vt/vttablet/tabletserver/tabletserver.go
2370+++ b/go/vt/vttablet/tabletserver/tabletserver.go
2371@@ -31,6 +31,7 @@ import (
2372
2373 "golang.org/x/net/context"
2374 "vitess.io/vitess/go/acl"
2375+ "vitess.io/vitess/go/context2"
2376 "vitess.io/vitess/go/history"
2377 "vitess.io/vitess/go/mysql"
2378 "vitess.io/vitess/go/sqltypes"
2379@@ -2016,7 +2017,7 @@ func (tsv *TabletServer) UpdateStream(ctx context.Context, target *querypb.Targe
2380 s := binlog.NewEventStreamer(tsv.dbconfigs.DbaWithDB(), tsv.se, p, timestamp, callback)
2381
2382 // Create a cancelable wrapping context.
2383- streamCtx, streamCancel := context.WithCancel(ctx)
2384+ streamCtx, streamCancel := context2.WithCancel(ctx, "./go/vt/vttablet/tabletserver/tabletserver.go:2019")
2385 i := tsv.updateStreamList.Add(streamCancel)
2386 defer tsv.updateStreamList.Delete(i)
2387
2388@@ -2318,7 +2319,7 @@ func withTimeout(ctx context.Context, timeout time.Duration, options *querypb.Ex
2389 if timeout == 0 || options.GetWorkload() == querypb.ExecuteOptions_DBA || tabletenv.IsLocalContext(ctx) {
2390 return ctx, func() {}
2391 }
2392- return context.WithTimeout(ctx, timeout)
2393+ return context2.WithTimeout(ctx, timeout, "./go/vt/vttablet/tabletserver/tabletserver.go:2321")
2394 }
2395
2396 // skipQueryPlanCache returns true if the query plan should be cached
2397diff --git a/go/vt/vttablet/tabletserver/tabletserver_test.go b/go/vt/vttablet/tabletserver/tabletserver_test.go
2398index ca5d2c38d..71f8c4218 100644
2399--- a/go/vt/vttablet/tabletserver/tabletserver_test.go
2400+++ b/go/vt/vttablet/tabletserver/tabletserver_test.go
2401@@ -32,6 +32,7 @@ import (
2402 "github.com/golang/protobuf/proto"
2403 "golang.org/x/net/context"
2404
2405+ "vitess.io/vitess/go/context2"
2406 "vitess.io/vitess/go/mysql"
2407 "vitess.io/vitess/go/mysql/fakesqldb"
2408 "vitess.io/vitess/go/sqltypes"
2409@@ -958,7 +959,7 @@ func TestTabletServerBeginFail(t *testing.T) {
2410 t.Fatalf("StartService failed: %v", err)
2411 }
2412 defer tsv.StopService()
2413- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Nanosecond)
2414+ ctx, cancel := context2.WithTimeout(context.Background(), 1*time.Nanosecond, "./go/vt/vttablet/tabletserver/tabletserver_test.go:961")
2415 defer cancel()
2416 tsv.Begin(ctx, &target, nil)
2417 _, err = tsv.Begin(ctx, &target, nil)
2418@@ -2092,7 +2093,7 @@ func TestSerializeTransactionsSameRow_RequestCanceled(t *testing.T) {
2419 }()
2420
2421 // tx2.
2422- ctxTx2, cancelTx2 := context.WithCancel(ctx)
2423+ ctxTx2, cancelTx2 := context2.WithCancel(ctx, "./go/vt/vttablet/tabletserver/tabletserver_test.go:2095")
2424 wg.Add(1)
2425 go func() {
2426 defer wg.Done()
2427diff --git a/go/vt/vttablet/tabletserver/tx_engine.go b/go/vt/vttablet/tabletserver/tx_engine.go
2428index 148569a02..e9c73da0f 100644
2429--- a/go/vt/vttablet/tabletserver/tx_engine.go
2430+++ b/go/vt/vttablet/tabletserver/tx_engine.go
2431@@ -23,6 +23,7 @@ import (
2432
2433 "golang.org/x/net/context"
2434
2435+ "vitess.io/vitess/go/context2"
2436 "vitess.io/vitess/go/timer"
2437 "vitess.io/vitess/go/trace"
2438 "vitess.io/vitess/go/vt/concurrency"
2439@@ -541,7 +542,7 @@ func (te *TxEngine) rollbackPrepared() {
2440 // transactions and calls the notifier on them.
2441 func (te *TxEngine) startWatchdog() {
2442 te.ticks.Start(func() {
2443- ctx, cancel := context.WithTimeout(tabletenv.LocalContext(), te.abandonAge/4)
2444+ ctx, cancel := context2.WithTimeout(tabletenv.LocalContext(), te.abandonAge/4, "./go/vt/vttablet/tabletserver/tx_engine.go:544")
2445 defer cancel()
2446
2447 // Raise alerts on prepares that have been unresolved for too long.
2448diff --git a/go/vt/vttablet/tabletserver/tx_prep_pool.go b/go/vt/vttablet/tabletserver/tx_prep_pool.go
2449index 184431cc4..6de13cb1b 100644
2450--- a/go/vt/vttablet/tabletserver/tx_prep_pool.go
2451+++ b/go/vt/vttablet/tabletserver/tx_prep_pool.go
2452@@ -24,7 +24,7 @@ import (
2453
2454 var (
2455 errPrepCommitting = errors.New("committing")
2456- errPrepFailed = errors.New("failed")
2457+ errPrepFailed = errors.New("failed")
2458 )
2459
2460 // TxPreparedPool manages connections for prepared transactions.
2461diff --git a/go/vt/vttablet/tabletserver/txserializer/tx_serializer_test.go b/go/vt/vttablet/tabletserver/txserializer/tx_serializer_test.go
2462index bc64e396a..2117fb957 100644
2463--- a/go/vt/vttablet/tabletserver/txserializer/tx_serializer_test.go
2464+++ b/go/vt/vttablet/tabletserver/txserializer/tx_serializer_test.go
2465@@ -27,6 +27,7 @@ import (
2466
2467 "golang.org/x/net/context"
2468
2469+ "vitess.io/vitess/go/context2"
2470 "vitess.io/vitess/go/streamlog"
2471 "vitess.io/vitess/go/vt/vterrors"
2472
2473@@ -306,7 +307,7 @@ func TestTxSerializerCancel(t *testing.T) {
2474 }
2475
2476 // tx3 (gets queued and must wait).
2477- ctx3, cancel3 := context.WithCancel(context.Background())
2478+ ctx3, cancel3 := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/txserializer/tx_serializer_test.go:309")
2479 wg := sync.WaitGroup{}
2480 wg.Add(1)
2481 go func() {
2482diff --git a/go/vt/vttablet/tabletserver/vstreamer/engine_test.go b/go/vt/vttablet/tabletserver/vstreamer/engine_test.go
2483index c88a9aeef..1578ff723 100644
2484--- a/go/vt/vttablet/tabletserver/vstreamer/engine_test.go
2485+++ b/go/vt/vttablet/tabletserver/vstreamer/engine_test.go
2486@@ -23,6 +23,7 @@ import (
2487
2488 "golang.org/x/net/context"
2489
2490+ "vitess.io/vitess/go/context2"
2491 binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
2492 )
2493
2494@@ -53,7 +54,7 @@ func TestUpdateVSchema(t *testing.T) {
2495 defer env.SetVSchema("{}")
2496
2497 // We have to start at least one stream to start the vschema watcher.
2498- ctx, cancel := context.WithCancel(context.Background())
2499+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/engine_test.go:56")
2500 defer cancel()
2501
2502 filter := &binlogdatapb.Filter{
2503diff --git a/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go b/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go
2504index c4114d451..ce98a74dd 100644
2505--- a/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go
2506+++ b/go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go
2507@@ -20,6 +20,7 @@ import (
2508 "context"
2509 "fmt"
2510
2511+ "vitess.io/vitess/go/context2"
2512 "vitess.io/vitess/go/mysql"
2513 "vitess.io/vitess/go/sqltypes"
2514 "vitess.io/vitess/go/vt/dbconfigs"
2515@@ -49,7 +50,7 @@ type rowStreamer struct {
2516 }
2517
2518 func newRowStreamer(ctx context.Context, cp *mysql.ConnParams, se *schema.Engine, query string, lastpk []sqltypes.Value, kschema *vindexes.KeyspaceSchema, send func(*binlogdatapb.VStreamRowsResponse) error) *rowStreamer {
2519- ctx, cancel := context.WithCancel(ctx)
2520+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/tabletserver/vstreamer/rowstreamer.go:52")
2521 return &rowStreamer{
2522 ctx: ctx,
2523 cancel: cancel,
2524diff --git a/go/vt/vttablet/tabletserver/vstreamer/rowstreamer_test.go b/go/vt/vttablet/tabletserver/vstreamer/rowstreamer_test.go
2525index c57135f4d..918db73a7 100644
2526--- a/go/vt/vttablet/tabletserver/vstreamer/rowstreamer_test.go
2527+++ b/go/vt/vttablet/tabletserver/vstreamer/rowstreamer_test.go
2528@@ -22,6 +22,7 @@ import (
2529 "testing"
2530 "time"
2531
2532+ "vitess.io/vitess/go/context2"
2533 "vitess.io/vitess/go/sqltypes"
2534
2535 binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
2536@@ -253,7 +254,7 @@ func TestStreamRowsCancel(t *testing.T) {
2537 })
2538 engine.se.Reload(context.Background())
2539
2540- ctx, cancel := context.WithCancel(context.Background())
2541+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/rowstreamer_test.go:256")
2542 defer cancel()
2543
2544 err := engine.StreamRows(ctx, "select * from t1", nil, func(rows *binlogdatapb.VStreamRowsResponse) error {
2545diff --git a/go/vt/vttablet/tabletserver/vstreamer/vstreamer.go b/go/vt/vttablet/tabletserver/vstreamer/vstreamer.go
2546index 91e09e8f3..76ddd1cf8 100644
2547--- a/go/vt/vttablet/tabletserver/vstreamer/vstreamer.go
2548+++ b/go/vt/vttablet/tabletserver/vstreamer/vstreamer.go
2549@@ -23,6 +23,7 @@ import (
2550 "io"
2551 "time"
2552
2553+ "vitess.io/vitess/go/context2"
2554 "vitess.io/vitess/go/mysql"
2555 "vitess.io/vitess/go/sqltypes"
2556 "vitess.io/vitess/go/vt/binlog"
2557@@ -70,7 +71,7 @@ type streamerPlan struct {
2558 }
2559
2560 func newVStreamer(ctx context.Context, cp *mysql.ConnParams, se *schema.Engine, startPos string, filter *binlogdatapb.Filter, kschema *vindexes.KeyspaceSchema, send func([]*binlogdatapb.VEvent) error) *vstreamer {
2561- ctx, cancel := context.WithCancel(ctx)
2562+ ctx, cancel := context2.WithCancel(ctx, "./go/vt/vttablet/tabletserver/vstreamer/vstreamer.go:73")
2563 return &vstreamer{
2564 ctx: ctx,
2565 cancel: cancel,
2566diff --git a/go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go b/go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go
2567index baa49af74..eab8df500 100644
2568--- a/go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go
2569+++ b/go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go
2570@@ -23,6 +23,7 @@ import (
2571
2572 "golang.org/x/net/context"
2573
2574+ "vitess.io/vitess/go/context2"
2575 "vitess.io/vitess/go/mysql"
2576
2577 binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata"
2578@@ -193,7 +194,7 @@ func TestREKeyRange(t *testing.T) {
2579 }
2580 defer env.SetVSchema("{}")
2581
2582- ctx, cancel := context.WithCancel(context.Background())
2583+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go:196")
2584 defer cancel()
2585
2586 filter := &binlogdatapb.Filter{
2587@@ -340,7 +341,7 @@ func TestDDLAddColumn(t *testing.T) {
2588 })
2589 engine.se.Reload(context.Background())
2590
2591- ctx, cancel := context.WithCancel(context.Background())
2592+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go:343")
2593 defer cancel()
2594
2595 // Test RE as well as select-based filters.
2596@@ -406,7 +407,7 @@ func TestDDLDropColumn(t *testing.T) {
2597 })
2598 engine.se.Reload(context.Background())
2599
2600- ctx, cancel := context.WithCancel(context.Background())
2601+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go:409")
2602 defer cancel()
2603
2604 ch := make(chan []*binlogdatapb.VEvent)
2605@@ -771,7 +772,7 @@ func TestMinimalMode(t *testing.T) {
2606 "set @@session.binlog_row_image='full'",
2607 })
2608
2609- ctx, cancel := context.WithCancel(context.Background())
2610+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go:774")
2611 defer cancel()
2612
2613 ch := make(chan []*binlogdatapb.VEvent)
2614@@ -810,7 +811,7 @@ func TestStatementMode(t *testing.T) {
2615 "set @@session.binlog_format='row'",
2616 })
2617
2618- ctx, cancel := context.WithCancel(context.Background())
2619+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go:813")
2620 defer cancel()
2621
2622 ch := make(chan []*binlogdatapb.VEvent)
2623@@ -829,7 +830,7 @@ func TestStatementMode(t *testing.T) {
2624
2625 func runCases(t *testing.T, filter *binlogdatapb.Filter, testcases []testcase) {
2626 t.Helper()
2627- ctx, cancel := context.WithCancel(context.Background())
2628+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/vttablet/tabletserver/vstreamer/vstreamer_test.go:832")
2629 defer cancel()
2630
2631 ch := startStream(ctx, t, filter)
2632diff --git a/go/vt/vttest/mysqlctl.go b/go/vt/vttest/mysqlctl.go
2633index d7e135dbf..8a7f6b4fa 100644
2634--- a/go/vt/vttest/mysqlctl.go
2635+++ b/go/vt/vttest/mysqlctl.go
2636@@ -25,6 +25,7 @@ import (
2637 "strings"
2638 "time"
2639
2640+ "vitess.io/vitess/go/context2"
2641 "vitess.io/vitess/go/mysql"
2642 )
2643
2644@@ -52,7 +53,7 @@ type Mysqlctl struct {
2645 // Setup spawns a new mysqld service and initializes it with the defaults.
2646 // The service is kept running in the background until TearDown() is called.
2647 func (ctl *Mysqlctl) Setup() error {
2648- ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
2649+ ctx, cancel := context2.WithTimeout(context.Background(), 60*time.Second, "./go/vt/vttest/mysqlctl.go:55")
2650 defer cancel()
2651
2652 cmd := exec.CommandContext(ctx,
2653@@ -76,7 +77,7 @@ func (ctl *Mysqlctl) Setup() error {
2654
2655 // TearDown shutdowns the running mysqld service
2656 func (ctl *Mysqlctl) TearDown() error {
2657- ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second)
2658+ ctx, cancel := context2.WithTimeout(context.Background(), 60*time.Second, "./go/vt/vttest/mysqlctl.go:79")
2659 defer cancel()
2660
2661 cmd := exec.CommandContext(ctx,
2662diff --git a/go/vt/worker/chunk.go b/go/vt/worker/chunk.go
2663index 4b775b470..1b9b9e80b 100644
2664--- a/go/vt/worker/chunk.go
2665+++ b/go/vt/worker/chunk.go
2666@@ -19,6 +19,7 @@ package worker
2667 import (
2668 "fmt"
2669
2670+ "vitess.io/vitess/go/context2"
2671 "vitess.io/vitess/go/vt/proto/vtrpc"
2672 "vitess.io/vitess/go/vt/vterrors"
2673
2674@@ -94,7 +95,7 @@ func generateChunks(ctx context.Context, wr *wrangler.Wrangler, tablet *topodata
2675
2676 // Get the MIN and MAX of the leading column of the primary key.
2677 query := fmt.Sprintf("SELECT MIN(%v), MAX(%v) FROM %v.%v", sqlescape.EscapeID(td.PrimaryKeyColumns[0]), sqlescape.EscapeID(td.PrimaryKeyColumns[0]), sqlescape.EscapeID(topoproto.TabletDbName(tablet)), sqlescape.EscapeID(td.Name))
2678- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2679+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/chunk.go:97")
2680 qr, err := wr.TabletManagerClient().ExecuteFetchAsApp(shortCtx, tablet, true, []byte(query), 1)
2681 cancel()
2682 if err != nil {
2683diff --git a/go/vt/worker/diff_utils.go b/go/vt/worker/diff_utils.go
2684index 19d2dcbca..895267e0f 100644
2685--- a/go/vt/worker/diff_utils.go
2686+++ b/go/vt/worker/diff_utils.go
2687@@ -25,6 +25,7 @@ import (
2688 "strings"
2689 "time"
2690
2691+ "vitess.io/vitess/go/context2"
2692 "vitess.io/vitess/go/vt/proto/vtrpc"
2693 "vitess.io/vitess/go/vt/vterrors"
2694 "vitess.io/vitess/go/vt/vttablet/tmclient"
2695@@ -63,7 +64,7 @@ type QueryResultReader struct {
2696 // NewQueryResultReaderForTablet creates a new QueryResultReader for
2697 // the provided tablet / sql query
2698 func NewQueryResultReaderForTablet(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, sql string) (*QueryResultReader, error) {
2699- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2700+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/diff_utils.go:66")
2701 tablet, err := ts.GetTablet(shortCtx, tabletAlias)
2702 cancel()
2703 if err != nil {
2704@@ -97,7 +98,7 @@ func NewQueryResultReaderForTablet(ctx context.Context, ts *topo.Server, tabletA
2705 // NewTransactionalQueryResultReaderForTablet creates a new QueryResultReader for
2706 // the provided tablet / sql query, and runs it in an existing transaction
2707 func NewTransactionalQueryResultReaderForTablet(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, sql string, txID int64) (*QueryResultReader, error) {
2708- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2709+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/diff_utils.go:100")
2710 tablet, err := ts.GetTablet(shortCtx, tabletAlias)
2711 cancel()
2712 if err != nil {
2713@@ -130,7 +131,7 @@ func NewTransactionalQueryResultReaderForTablet(ctx context.Context, ts *topo.Se
2714
2715 // RollbackTransaction rolls back the transaction
2716 func RollbackTransaction(ctx context.Context, ts *topo.Server, tabletAlias *topodatapb.TabletAlias, txID int64) error {
2717- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2718+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/diff_utils.go:133")
2719 tablet, err := ts.GetTablet(shortCtx, tabletAlias)
2720 cancel()
2721 if err != nil {
2722diff --git a/go/vt/worker/executor.go b/go/vt/worker/executor.go
2723index 07ec11d13..32a6beb2c 100644
2724--- a/go/vt/worker/executor.go
2725+++ b/go/vt/worker/executor.go
2726@@ -20,6 +20,7 @@ import (
2727 "fmt"
2728 "time"
2729
2730+ "vitess.io/vitess/go/context2"
2731 "vitess.io/vitess/go/vt/vterrors"
2732
2733 "golang.org/x/net/context"
2734@@ -117,7 +118,7 @@ func (e *executor) refreshState(ctx context.Context) error {
2735 func (e *executor) fetchWithRetries(ctx context.Context, action func(ctx context.Context, tablet *topodatapb.Tablet) error) error {
2736 retryDuration := *retryDuration
2737 // We should keep retrying up until the retryCtx runs out.
2738- retryCtx, retryCancel := context.WithTimeout(ctx, retryDuration)
2739+ retryCtx, retryCancel := context2.WithTimeout(ctx, retryDuration, "./go/vt/worker/executor.go:120")
2740 defer retryCancel()
2741 // Is this current attempt a retry of a previous attempt?
2742 isRetry := false
2743@@ -150,7 +151,7 @@ func (e *executor) fetchWithRetries(ctx context.Context, action func(ctx context
2744 // Run the command (in a block since goto above does not allow to introduce
2745 // new variables until the label is reached.)
2746 {
2747- tryCtx, cancel := context.WithTimeout(retryCtx, 2*time.Minute)
2748+ tryCtx, cancel := context2.WithTimeout(retryCtx, 2*time.Minute, "./go/vt/worker/executor.go:153")
2749 err = action(tryCtx, master.Tablet)
2750 cancel()
2751
2752diff --git a/go/vt/worker/instance.go b/go/vt/worker/instance.go
2753index 371ff734e..0bba03eff 100644
2754--- a/go/vt/worker/instance.go
2755+++ b/go/vt/worker/instance.go
2756@@ -24,6 +24,7 @@ import (
2757 "time"
2758
2759 "golang.org/x/net/context"
2760+ "vitess.io/vitess/go/context2"
2761 "vitess.io/vitess/go/trace"
2762
2763 "vitess.io/vitess/go/tb"
2764@@ -115,7 +116,7 @@ func (wi *Instance) setAndStartWorker(ctx context.Context, wrk Worker, wr *wrang
2765
2766 wi.currentWorker = wrk
2767 wi.currentMemoryLogger = logutil.NewMemoryLogger()
2768- wi.currentContext, wi.currentCancelFunc = context.WithCancel(ctx)
2769+ wi.currentContext, wi.currentCancelFunc = context2.WithCancel(ctx, "./go/vt/worker/instance.go:118")
2770 wi.lastRunError = nil
2771 wi.lastRunStopTime = time.Unix(0, 0)
2772 done := make(chan struct{})
2773diff --git a/go/vt/worker/legacy_split_clone.go b/go/vt/worker/legacy_split_clone.go
2774index a191a1b79..890a71207 100644
2775--- a/go/vt/worker/legacy_split_clone.go
2776+++ b/go/vt/worker/legacy_split_clone.go
2777@@ -27,6 +27,7 @@ import (
2778 "sync"
2779 "time"
2780
2781+ "vitess.io/vitess/go/context2"
2782 "vitess.io/vitess/go/vt/vterrors"
2783
2784 "golang.org/x/net/context"
2785@@ -266,7 +267,7 @@ func (scw *LegacySplitCloneWorker) init(ctx context.Context) error {
2786 var err error
2787
2788 // read the keyspace and validate it
2789- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2790+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:269")
2791 scw.keyspaceInfo, err = scw.wr.TopoServer().GetKeyspace(shortCtx, scw.keyspace)
2792 cancel()
2793 if err != nil {
2794@@ -274,7 +275,7 @@ func (scw *LegacySplitCloneWorker) init(ctx context.Context) error {
2795 }
2796
2797 // find the OverlappingShards in the keyspace
2798- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
2799+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:277")
2800 osList, err := topotools.FindOverlappingShards(shortCtx, scw.wr.TopoServer(), scw.keyspace)
2801 cancel()
2802 if err != nil {
2803@@ -367,7 +368,7 @@ func (scw *LegacySplitCloneWorker) findTargets(ctx context.Context) error {
2804 // get the tablet info for them, and stop their replication
2805 scw.sourceTablets = make([]*topodatapb.Tablet, len(scw.sourceAliases))
2806 for i, alias := range scw.sourceAliases {
2807- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2808+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:370")
2809 ti, err := scw.wr.TopoServer().GetTablet(shortCtx, alias)
2810 cancel()
2811 if err != nil {
2812@@ -375,7 +376,7 @@ func (scw *LegacySplitCloneWorker) findTargets(ctx context.Context) error {
2813 }
2814 scw.sourceTablets[i] = ti.Tablet
2815
2816- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
2817+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:378")
2818 err = scw.wr.TabletManagerClient().StopSlave(shortCtx, scw.sourceTablets[i])
2819 cancel()
2820 if err != nil {
2821@@ -398,7 +399,7 @@ func (scw *LegacySplitCloneWorker) findTargets(ctx context.Context) error {
2822 // Make sure we find a master for each destination shard and log it.
2823 scw.wr.Logger().Infof("Finding a MASTER tablet for each destination shard...")
2824 for _, si := range scw.destinationShards {
2825- waitCtx, waitCancel := context.WithTimeout(ctx, 10*time.Second)
2826+ waitCtx, waitCancel := context2.WithTimeout(ctx, 10*time.Second, "./go/vt/worker/legacy_split_clone.go:401")
2827 defer waitCancel()
2828 if err := scw.tsc.WaitForTablets(waitCtx, scw.cell, si.Keyspace(), si.ShardName(), topodatapb.TabletType_MASTER); err != nil {
2829 return vterrors.Wrapf(err, "cannot find MASTER tablet for destination shard for %v/%v", si.Keyspace(), si.ShardName())
2830@@ -410,7 +411,7 @@ func (scw *LegacySplitCloneWorker) findTargets(ctx context.Context) error {
2831 master := masters[0]
2832
2833 // Get the MySQL database name of the tablet.
2834- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2835+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:413")
2836 ti, err := scw.wr.TopoServer().GetTablet(shortCtx, master.Tablet.Alias)
2837 cancel()
2838 if err != nil {
2839@@ -453,7 +454,7 @@ func (scw *LegacySplitCloneWorker) copy(ctx context.Context) error {
2840 // on all source shards. Furthermore, we estimate the number of rows
2841 // in each source shard for each table to be about the same
2842 // (rowCount is used to estimate an ETA)
2843- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2844+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:456")
2845 sourceSchemaDefinition, err := scw.wr.GetSchema(shortCtx, scw.sourceAliases[0], nil, scw.excludeTables, false /* includeViews */)
2846 cancel()
2847 if err != nil {
2848@@ -476,7 +477,7 @@ func (scw *LegacySplitCloneWorker) copy(ctx context.Context) error {
2849 mu := sync.Mutex{}
2850 var firstError error
2851
2852- ctx, cancelCopy := context.WithCancel(ctx)
2853+ ctx, cancelCopy := context2.WithCancel(ctx, "./go/vt/worker/legacy_split_clone.go:479")
2854 processError := func(format string, args ...interface{}) {
2855 scw.wr.Logger().Errorf(format, args...)
2856 mu.Lock()
2857@@ -605,7 +606,7 @@ func (scw *LegacySplitCloneWorker) copy(ctx context.Context) error {
2858 sourcePositions := make([]string, len(scw.sourceShards))
2859 // get the current position from the sources
2860 for shardIndex := range scw.sourceShards {
2861- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2862+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/legacy_split_clone.go:608")
2863 status, err := scw.wr.TabletManagerClient().SlaveStatus(shortCtx, scw.sourceTablets[shardIndex])
2864 cancel()
2865 if err != nil {
2866diff --git a/go/vt/worker/legacy_split_clone_test.go b/go/vt/worker/legacy_split_clone_test.go
2867index 65494ade2..8f721a2c9 100644
2868--- a/go/vt/worker/legacy_split_clone_test.go
2869+++ b/go/vt/worker/legacy_split_clone_test.go
2870@@ -28,6 +28,7 @@ import (
2871
2872 "golang.org/x/net/context"
2873
2874+ "vitess.io/vitess/go/context2"
2875 "vitess.io/vitess/go/mysql"
2876 "vitess.io/vitess/go/mysql/fakesqldb"
2877 "vitess.io/vitess/go/sqltypes"
2878@@ -468,7 +469,7 @@ func TestLegacySplitCloneV2_NoMasterAvailable(t *testing.T) {
2879 statsRetryCounters.ResetAll()
2880 errs := make(chan error, 1)
2881 go func() {
2882- ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
2883+ ctx, cancel := context2.WithTimeout(context.Background(), 30*time.Second, "./go/vt/worker/legacy_split_clone_test.go:471")
2884 defer cancel()
2885
2886 for {
2887diff --git a/go/vt/worker/multi_split_diff.go b/go/vt/worker/multi_split_diff.go
2888index 9a93ca1e1..c43d6a3d4 100644
2889--- a/go/vt/worker/multi_split_diff.go
2890+++ b/go/vt/worker/multi_split_diff.go
2891@@ -24,6 +24,7 @@ import (
2892 "time"
2893
2894 "golang.org/x/net/context"
2895+ "vitess.io/vitess/go/context2"
2896 "vitess.io/vitess/go/vt/proto/vtrpc"
2897 "vitess.io/vitess/go/vt/vttablet/queryservice"
2898 "vitess.io/vitess/go/vt/vttablet/tabletconn"
2899@@ -200,13 +201,13 @@ func (msdw *MultiSplitDiffWorker) init(ctx context.Context) error {
2900 }
2901
2902 var err error
2903- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2904+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:203")
2905 msdw.keyspaceInfo, err = msdw.wr.TopoServer().GetKeyspace(shortCtx, msdw.keyspace)
2906 cancel()
2907 if err != nil {
2908 return vterrors.Wrapf(err, "cannot read keyspace %v", msdw.keyspace)
2909 }
2910- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
2911+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:209")
2912 msdw.shardInfo, err = msdw.wr.TopoServer().GetShard(shortCtx, msdw.keyspace, msdw.shard)
2913 cancel()
2914 if err != nil {
2915@@ -228,7 +229,7 @@ func (msdw *MultiSplitDiffWorker) init(ctx context.Context) error {
2916
2917 // findDestinationShards finds all the shards that have filtered replication from the source shard
2918 func (msdw *MultiSplitDiffWorker) findDestinationShards(ctx context.Context) ([]*topo.ShardInfo, error) {
2919- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2920+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:231")
2921 keyspaces, err := msdw.wr.TopoServer().GetKeyspaces(shortCtx)
2922 cancel()
2923 if err != nil {
2924@@ -252,7 +253,7 @@ func (msdw *MultiSplitDiffWorker) findDestinationShards(ctx context.Context) ([]
2925 }
2926
2927 func (msdw *MultiSplitDiffWorker) findShardsInKeyspace(ctx context.Context, keyspace string) ([]*topo.ShardInfo, error) {
2928- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2929+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:255")
2930 shards, err := msdw.wr.TopoServer().GetShardNames(shortCtx, keyspace)
2931 cancel()
2932 if err != nil {
2933@@ -284,7 +285,7 @@ func (msdw *MultiSplitDiffWorker) findShardsInKeyspace(ctx context.Context, keys
2934 }
2935
2936 func (msdw *MultiSplitDiffWorker) getShardInfo(ctx context.Context, keyspace string, shard string) (*topo.ShardInfo, uint32, error) {
2937- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2938+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:287")
2939 si, err := msdw.wr.TopoServer().GetShard(shortCtx, keyspace, shard)
2940 cancel()
2941 if err != nil {
2942@@ -349,14 +350,14 @@ func (msdw *MultiSplitDiffWorker) stopVreplicationOnAll(ctx context.Context, tab
2943 tablet := tabletInfo[i].Tablet
2944
2945 msdw.wr.Logger().Infof("stopping master binlog replication on %v", shardInfo.MasterAlias)
2946- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2947+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:352")
2948 _, err := msdw.wr.TabletManagerClient().VReplicationExec(shortCtx, tablet, binlogplayer.StopVReplication(msdw.sourceUID, "for split diff"))
2949 cancel()
2950 if err != nil {
2951 return nil, vterrors.Wrapf(err, "VReplicationExec(stop) for %v failed", shardInfo.MasterAlias)
2952 }
2953 wrangler.RecordVReplicationAction(msdw.cleaner, tablet, binlogplayer.StartVReplication(msdw.sourceUID))
2954- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
2955+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:359")
2956 p3qr, err := msdw.wr.TabletManagerClient().VReplicationExec(shortCtx, tablet, binlogplayer.ReadVReplicationPos(msdw.sourceUID))
2957 cancel()
2958 if err != nil {
2959@@ -375,7 +376,7 @@ func (msdw *MultiSplitDiffWorker) stopVreplicationOnAll(ctx context.Context, tab
2960 }
2961
2962 func (msdw *MultiSplitDiffWorker) getMasterTabletInfoForShard(ctx context.Context, shardInfo *topo.ShardInfo) (*topo.TabletInfo, error) {
2963- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2964+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:378")
2965 masterInfo, err := msdw.wr.TopoServer().GetTablet(shortCtx, shardInfo.MasterAlias)
2966 cancel()
2967 if err != nil {
2968@@ -389,7 +390,7 @@ func (msdw *MultiSplitDiffWorker) getMasterTabletInfoForShard(ctx context.Contex
2969 // (add a cleanup task to restart binlog replication on the source tablet, and
2970 // change the existing ChangeSlaveType cleanup action to 'spare' type)
2971 func (msdw *MultiSplitDiffWorker) stopReplicationOnSourceTabletAt(ctx context.Context, destVreplicationPos []string) (string, error) {
2972- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2973+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:392")
2974 sourceTablet, err := msdw.wr.TopoServer().GetTablet(shortCtx, msdw.sourceAlias)
2975 cancel()
2976 if err != nil {
2977@@ -406,14 +407,14 @@ func (msdw *MultiSplitDiffWorker) stopReplicationOnSourceTabletAt(ctx context.Co
2978
2979 msdw.wr.Logger().Infof("stopping slave %v at a minimum of %v", msdw.sourceAlias, vreplicationPos)
2980
2981- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
2982+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:409")
2983 msdw.wr.TabletManagerClient().StartSlave(shortCtx, sourceTablet.Tablet)
2984 cancel()
2985 if err != nil {
2986 return "", err
2987 }
2988
2989- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
2990+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:416")
2991 mysqlPos, err = msdw.wr.TabletManagerClient().StopSlaveMinimum(shortCtx, sourceTablet.Tablet, vreplicationPos, *remoteActionsTimeout)
2992 cancel()
2993 if err != nil {
2994@@ -431,21 +432,21 @@ func (msdw *MultiSplitDiffWorker) stopReplicationOnSourceTabletAt(ctx context.Co
2995 // up to the specified source position, and return the destination position.
2996 func (msdw *MultiSplitDiffWorker) stopVreplicationAt(ctx context.Context, shardInfo *topo.ShardInfo, sourcePosition string, masterInfo *topo.TabletInfo) (string, error) {
2997 msdw.wr.Logger().Infof("Restarting master %v until it catches up to %v", shardInfo.MasterAlias, sourcePosition)
2998- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
2999+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:434")
3000 _, err := msdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StartVReplicationUntil(msdw.sourceUID, sourcePosition))
3001 cancel()
3002 if err != nil {
3003 return "", vterrors.Wrapf(err, "VReplication(start until) for %v until %v failed", shardInfo.MasterAlias, sourcePosition)
3004 }
3005
3006- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3007+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:441")
3008 err = msdw.wr.TabletManagerClient().VReplicationWaitForPos(shortCtx, masterInfo.Tablet, int(msdw.sourceUID), sourcePosition)
3009 cancel()
3010 if err != nil {
3011 return "", vterrors.Wrapf(err, "VReplicationWaitForPos for %v until %v failed", shardInfo.MasterAlias, sourcePosition)
3012 }
3013
3014- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3015+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:448")
3016 masterPos, err := msdw.wr.TabletManagerClient().MasterPosition(shortCtx, masterInfo.Tablet)
3017 cancel()
3018 if err != nil {
3019@@ -464,7 +465,7 @@ func (msdw *MultiSplitDiffWorker) stopReplicationAt(ctx context.Context, destina
3020 } else {
3021 msdw.wr.Logger().Infof("waiting for destination tablet %v to catch up to %v", destinationAlias, masterPos)
3022 }
3023- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3024+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:467")
3025 destinationTablet, err := msdw.wr.TopoServer().GetTablet(shortCtx, destinationAlias)
3026 cancel()
3027 if err != nil {
3028@@ -475,7 +476,7 @@ func (msdw *MultiSplitDiffWorker) stopReplicationAt(ctx context.Context, destina
3029 time.Sleep(1 * time.Minute)
3030 }
3031
3032- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3033+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:478")
3034 if msdw.waitForFixedTimeRatherThanGtidSet {
3035 err = msdw.wr.TabletManagerClient().StopSlave(shortCtx, destinationTablet.Tablet)
3036 } else {
3037@@ -493,7 +494,7 @@ func (msdw *MultiSplitDiffWorker) stopReplicationAt(ctx context.Context, destina
3038 // (remove the cleanup task that does the same)
3039 func (msdw *MultiSplitDiffWorker) startVreplication(ctx context.Context, shardInfo *topo.ShardInfo, masterInfo *topo.TabletInfo) error {
3040 msdw.wr.Logger().Infof("restarting filtered replication on master %v", shardInfo.MasterAlias)
3041- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3042+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:496")
3043 _, err := msdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StartVReplication(msdw.sourceUID))
3044 if err != nil {
3045 return vterrors.Wrapf(err, "VReplicationExec(start) failed for %v", shardInfo.MasterAlias)
3046@@ -560,7 +561,7 @@ func (msdw *MultiSplitDiffWorker) synchronizeSrcAndDestTxState(ctx context.Conte
3047 }
3048 }
3049
3050- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3051+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:563")
3052 source, _ := msdw.wr.TopoServer().GetTablet(shortCtx, msdw.sourceAlias)
3053 cancel()
3054
3055@@ -604,7 +605,7 @@ func (msdw *MultiSplitDiffWorker) synchronizeSrcAndDestTxState(ctx context.Conte
3056 return err
3057 }
3058
3059- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3060+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:607")
3061 destTabletInfo, err := msdw.wr.TopoServer().GetTablet(shortCtx, destinationAlias)
3062 cancel()
3063 if err != nil {
3064@@ -652,7 +653,7 @@ func (msdw *MultiSplitDiffWorker) synchronizeSrcAndDestTxState(ctx context.Conte
3065
3066 func (msdw *MultiSplitDiffWorker) waitForDestinationTabletToReach(ctx context.Context, tablet *topodatapb.Tablet, mysqlPos string) error {
3067 for i := 0; i < 20; i++ {
3068- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3069+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:655")
3070 pos, err := msdw.wr.TabletManagerClient().MasterPosition(shortCtx, tablet)
3071 cancel()
3072 if err != nil {
3073@@ -758,7 +759,7 @@ func (msdw *MultiSplitDiffWorker) gatherSchemaInfo(ctx context.Context) ([]*tabl
3074 wg.Add(1)
3075 go func(i int, destinationAlias *topodatapb.TabletAlias) {
3076 var err error
3077- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3078+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:761")
3079 destinationSchemaDefinition, err := msdw.wr.GetSchema(
3080 shortCtx, destinationAlias, nil /* tables */, msdw.excludeTables, false /* includeViews */)
3081 cancel()
3082@@ -773,7 +774,7 @@ func (msdw *MultiSplitDiffWorker) gatherSchemaInfo(ctx context.Context) ([]*tabl
3083 wg.Add(1)
3084 go func() {
3085 var err error
3086- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3087+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff.go:776")
3088 sourceSchemaDefinition, err = msdw.wr.GetSchema(
3089 shortCtx, msdw.sourceAlias, nil /* tables */, msdw.excludeTables, false /* includeViews */)
3090 cancel()
3091@@ -811,7 +812,7 @@ func (msdw *MultiSplitDiffWorker) diffSchemaInformation(ctx context.Context, des
3092 }
3093
3094 func (msdw *MultiSplitDiffWorker) loadVSchema(ctx context.Context) (*vindexes.KeyspaceSchema, error) {
3095- shortCtx, cancel := context.WithCancel(ctx)
3096+ shortCtx, cancel := context2.WithCancel(ctx, "./go/vt/worker/multi_split_diff.go:814")
3097 kschema, err := msdw.wr.TopoServer().GetVSchema(shortCtx, msdw.keyspace)
3098 cancel()
3099 if err != nil {
3100diff --git a/go/vt/worker/multi_split_diff_cmd.go b/go/vt/worker/multi_split_diff_cmd.go
3101index 5a6b880c5..1c6cb4e42 100644
3102--- a/go/vt/worker/multi_split_diff_cmd.go
3103+++ b/go/vt/worker/multi_split_diff_cmd.go
3104@@ -25,6 +25,7 @@ import (
3105 "strings"
3106 "sync"
3107
3108+ "vitess.io/vitess/go/context2"
3109 "vitess.io/vitess/go/vt/proto/topodata"
3110 "vitess.io/vitess/go/vt/proto/vtrpc"
3111 "vitess.io/vitess/go/vt/vterrors"
3112@@ -123,7 +124,7 @@ func commandMultiSplitDiff(wi *Instance, wr *wrangler.Wrangler, subFlags *flag.F
3113
3114 // shardSources returns all the shards that are SourceShards of at least one other shard.
3115 func shardSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string]string, error) {
3116- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3117+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff_cmd.go:126")
3118 keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
3119 cancel()
3120 if err != nil {
3121@@ -139,7 +140,7 @@ func shardSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string]stri
3122 wg.Add(1)
3123 go func(keyspace string) {
3124 defer wg.Done()
3125- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3126+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff_cmd.go:142")
3127 shards, err := wr.TopoServer().GetShardNames(shortCtx, keyspace)
3128 cancel()
3129 if err != nil {
3130@@ -150,7 +151,7 @@ func shardSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string]stri
3131 wg.Add(1)
3132 go func(keyspace, shard string) {
3133 defer wg.Done()
3134- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3135+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/multi_split_diff_cmd.go:153")
3136 si, err := wr.TopoServer().GetShard(shortCtx, keyspace, shard)
3137 cancel()
3138 if err != nil {
3139diff --git a/go/vt/worker/restartable_result_reader.go b/go/vt/worker/restartable_result_reader.go
3140index 04f95695f..995096e96 100644
3141--- a/go/vt/worker/restartable_result_reader.go
3142+++ b/go/vt/worker/restartable_result_reader.go
3143@@ -22,6 +22,7 @@ import (
3144 "strings"
3145 "time"
3146
3147+ "vitess.io/vitess/go/context2"
3148 "vitess.io/vitess/go/vt/vterrors"
3149
3150 "golang.org/x/net/context"
3151@@ -225,7 +226,7 @@ func (r *RestartableResultReader) Next() (*sqltypes.Result, error) {
3152
3153 func (r *RestartableResultReader) nextWithRetries() (*sqltypes.Result, error) {
3154 // In case of errors we will keep retrying until retryCtx is done.
3155- retryCtx, retryCancel := context.WithTimeout(r.ctx, *retryDuration)
3156+ retryCtx, retryCancel := context2.WithTimeout(r.ctx, *retryDuration, "./go/vt/worker/restartable_result_reader.go:228")
3157 defer retryCancel()
3158
3159 // The first retry is the second attempt because we already tried once in Next()
3160diff --git a/go/vt/worker/split_clone.go b/go/vt/worker/split_clone.go
3161index 8b8cd2d00..39fa401c7 100644
3162--- a/go/vt/worker/split_clone.go
3163+++ b/go/vt/worker/split_clone.go
3164@@ -25,6 +25,7 @@ import (
3165
3166 "golang.org/x/net/context"
3167
3168+ "vitess.io/vitess/go/context2"
3169 "vitess.io/vitess/go/event"
3170 "vitess.io/vitess/go/stats"
3171 "vitess.io/vitess/go/vt/binlog/binlogplayer"
3172@@ -527,7 +528,7 @@ func (scw *SplitCloneWorker) init(ctx context.Context) error {
3173 scw.setState(WorkerStateInit)
3174
3175 // read the keyspace and validate it
3176- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3177+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:530")
3178 var err error
3179 scw.destinationKeyspaceInfo, err = scw.wr.TopoServer().GetKeyspace(shortCtx, scw.destinationKeyspace)
3180 cancel()
3181@@ -577,7 +578,7 @@ func (scw *SplitCloneWorker) init(ctx context.Context) error {
3182
3183 func (scw *SplitCloneWorker) initShardsForHorizontalResharding(ctx context.Context) error {
3184 // find the OverlappingShards in the keyspace
3185- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3186+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:580")
3187 osList, err := topotools.FindOverlappingShards(shortCtx, scw.wr.TopoServer(), scw.destinationKeyspace)
3188 cancel()
3189 if err != nil {
3190@@ -634,7 +635,7 @@ func (scw *SplitCloneWorker) initShardsForVerticalSplit(ctx context.Context) err
3191 }
3192 sourceKeyspace := servedFrom
3193
3194- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3195+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:637")
3196 shardMap, err := scw.wr.TopoServer().FindAllShardsInKeyspace(shortCtx, sourceKeyspace)
3197 cancel()
3198 if err != nil {
3199@@ -774,7 +775,7 @@ func (scw *SplitCloneWorker) findOfflineSourceTablets(ctx context.Context) error
3200 // get the tablet info for them, and stop their replication
3201 scw.sourceTablets = make([]*topodatapb.Tablet, len(scw.sourceAliases))
3202 for i, alias := range scw.sourceAliases {
3203- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3204+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:777")
3205 ti, err := scw.wr.TopoServer().GetTablet(shortCtx, alias)
3206 cancel()
3207 if err != nil {
3208@@ -782,7 +783,7 @@ func (scw *SplitCloneWorker) findOfflineSourceTablets(ctx context.Context) error
3209 }
3210 scw.sourceTablets[i] = ti.Tablet
3211
3212- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3213+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:785")
3214 err = scw.wr.TabletManagerClient().StopSlave(shortCtx, scw.sourceTablets[i])
3215 cancel()
3216 if err != nil {
3217@@ -817,7 +818,7 @@ func (scw *SplitCloneWorker) findTransactionalSources(ctx context.Context) error
3218
3219 // get the tablet info
3220 scw.sourceTablets = make([]*topodatapb.Tablet, 1)
3221- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3222+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:820")
3223 ti, err := scw.wr.TopoServer().GetTablet(shortCtx, scw.sourceAliases[0])
3224 cancel()
3225 if err != nil {
3226@@ -843,7 +844,7 @@ func (scw *SplitCloneWorker) findDestinationMasters(ctx context.Context) error {
3227 // Make sure we find a master for each destination shard and log it.
3228 scw.wr.Logger().Infof("Finding a MASTER tablet for each destination shard...")
3229 for _, si := range scw.destinationShards {
3230- waitCtx, waitCancel := context.WithTimeout(ctx, *waitForHealthyTabletsTimeout)
3231+ waitCtx, waitCancel := context2.WithTimeout(ctx, *waitForHealthyTabletsTimeout, "./go/vt/worker/split_clone.go:846")
3232 err := scw.tsc.WaitForTablets(waitCtx, scw.cell, si.Keyspace(), si.ShardName(), topodatapb.TabletType_MASTER)
3233 waitCancel()
3234 if err != nil {
3235@@ -1178,7 +1179,7 @@ func (scw *SplitCloneWorker) clone(ctx context.Context, state StatusWorkerState)
3236
3237 var firstError error
3238
3239- ctx, cancelCopy := context.WithCancel(ctx)
3240+ ctx, cancelCopy := context2.WithCancel(ctx, "./go/vt/worker/split_clone.go:1181")
3241 defer cancelCopy()
3242 processError := func(format string, args ...interface{}) {
3243 // in theory we could have two threads see firstError as null and both write to the variable
3244@@ -1245,7 +1246,7 @@ func (scw *SplitCloneWorker) setUpVReplication(ctx context.Context) error {
3245 sourcePositions[0] = scw.lastPos
3246 } else {
3247 for shardIndex := range scw.sourceShards {
3248- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3249+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:1248")
3250 status, err := scw.wr.TabletManagerClient().SlaveStatus(shortCtx, scw.sourceTablets[shardIndex])
3251 cancel()
3252 if err != nil {
3253@@ -1254,7 +1255,7 @@ func (scw *SplitCloneWorker) setUpVReplication(ctx context.Context) error {
3254 sourcePositions[shardIndex] = status.Position
3255 }
3256 }
3257- cancelableCtx, cancel := context.WithCancel(ctx)
3258+ cancelableCtx, cancel := context2.WithCancel(ctx, "./go/vt/worker/split_clone.go:1257")
3259 rec := concurrency.AllErrorRecorder{}
3260 handleError := func(e error) {
3261 rec.RecordError(e)
3262@@ -1319,7 +1320,7 @@ func (scw *SplitCloneWorker) getSourceSchema(ctx context.Context, tablet *topoda
3263 // on all source shards. Furthermore, we estimate the number of rows
3264 // in each source shard for each table to be about the same
3265 // (rowCount is used to estimate an ETA)
3266- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3267+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone.go:1322")
3268 sourceSchemaDefinition, err := scw.wr.GetSchema(shortCtx, tablet.Alias, scw.tables, scw.excludeTables, false /* includeViews */)
3269 cancel()
3270 if err != nil {
3271diff --git a/go/vt/worker/split_clone_cmd.go b/go/vt/worker/split_clone_cmd.go
3272index 4cf6b8795..da7782709 100644
3273--- a/go/vt/worker/split_clone_cmd.go
3274+++ b/go/vt/worker/split_clone_cmd.go
3275@@ -27,6 +27,7 @@ import (
3276
3277 "golang.org/x/net/context"
3278
3279+ "vitess.io/vitess/go/context2"
3280 "vitess.io/vitess/go/vt/concurrency"
3281 "vitess.io/vitess/go/vt/proto/topodata"
3282 "vitess.io/vitess/go/vt/proto/vtrpc"
3283@@ -151,7 +152,7 @@ func commandSplitClone(wi *Instance, wr *wrangler.Wrangler, subFlags *flag.FlagS
3284 }
3285
3286 func keyspacesWithOverlappingShards(ctx context.Context, wr *wrangler.Wrangler) ([]map[string]string, error) {
3287- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3288+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone_cmd.go:154")
3289 keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
3290 cancel()
3291 if err != nil {
3292@@ -166,7 +167,7 @@ func keyspacesWithOverlappingShards(ctx context.Context, wr *wrangler.Wrangler)
3293 wg.Add(1)
3294 go func(keyspace string) {
3295 defer wg.Done()
3296- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3297+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_clone_cmd.go:169")
3298 osList, err := topotools.FindOverlappingShards(shortCtx, wr.TopoServer(), keyspace)
3299 cancel()
3300 if err != nil {
3301diff --git a/go/vt/worker/split_clone_test.go b/go/vt/worker/split_clone_test.go
3302index 88a83ae6e..7cf717db9 100644
3303--- a/go/vt/worker/split_clone_test.go
3304+++ b/go/vt/worker/split_clone_test.go
3305@@ -27,6 +27,7 @@ import (
3306 "time"
3307
3308 "golang.org/x/net/context"
3309+ "vitess.io/vitess/go/context2"
3310 "vitess.io/vitess/go/mysql"
3311 "vitess.io/vitess/go/mysql/fakesqldb"
3312 "vitess.io/vitess/go/sqltypes"
3313@@ -1025,7 +1026,7 @@ func TestSplitCloneV2_NoMasterAvailable(t *testing.T) {
3314 // late because this Go routine looks at it and can run before the worker.
3315 statsRetryCounters.ResetAll()
3316 go func() {
3317- ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
3318+ ctx, cancel := context2.WithTimeout(context.Background(), 30*time.Second, "./go/vt/worker/split_clone_test.go:1028")
3319 defer cancel()
3320
3321 for {
3322diff --git a/go/vt/worker/split_diff.go b/go/vt/worker/split_diff.go
3323index 55b5c084f..0eeb44db6 100644
3324--- a/go/vt/worker/split_diff.go
3325+++ b/go/vt/worker/split_diff.go
3326@@ -21,6 +21,7 @@ import (
3327 "sort"
3328 "sync"
3329
3330+ "vitess.io/vitess/go/context2"
3331 "vitess.io/vitess/go/vt/proto/vtrpc"
3332 "vitess.io/vitess/go/vt/vterrors"
3333
3334@@ -187,13 +188,13 @@ func (sdw *SplitDiffWorker) init(ctx context.Context) error {
3335 sdw.SetState(WorkerStateInit)
3336
3337 var err error
3338- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3339+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:190")
3340 sdw.keyspaceInfo, err = sdw.wr.TopoServer().GetKeyspace(shortCtx, sdw.keyspace)
3341 cancel()
3342 if err != nil {
3343 return vterrors.Wrapf(err, "cannot read keyspace %v", sdw.keyspace)
3344 }
3345- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3346+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:196")
3347 sdw.shardInfo, err = sdw.wr.TopoServer().GetShard(shortCtx, sdw.keyspace, sdw.shard)
3348 cancel()
3349 if err != nil {
3350@@ -258,7 +259,7 @@ func (sdw *SplitDiffWorker) findTargets(ctx context.Context) error {
3351 // to FindWorkerTablet could attempt to set to DRAIN state the same tablet. Only
3352 // one of these calls to FindWorkerTablet will succeed and the rest will fail.
3353 // The following, makes sures we keep trying to find a worker tablet when this error occur.
3354- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3355+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:261")
3356 for {
3357 select {
3358 case <-shortCtx.Done():
3359@@ -297,7 +298,7 @@ func (sdw *SplitDiffWorker) findTargets(ctx context.Context) error {
3360 func (sdw *SplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3361 sdw.SetState(WorkerStateSyncReplication)
3362
3363- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3364+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:300")
3365 defer cancel()
3366 masterInfo, err := sdw.wr.TopoServer().GetTablet(shortCtx, sdw.shardInfo.MasterAlias)
3367 if err != nil {
3368@@ -306,7 +307,7 @@ func (sdw *SplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3369
3370 // 1 - stop the master binlog replication, get its current position
3371 sdw.wr.Logger().Infof("Stopping master binlog replication on %v", sdw.shardInfo.MasterAlias)
3372- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3373+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:309")
3374 defer cancel()
3375 _, err = sdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StopVReplication(sdw.sourceShard.Uid, "for split diff"))
3376 if err != nil {
3377@@ -331,7 +332,7 @@ func (sdw *SplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3378 return err
3379 }
3380
3381- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3382+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:334")
3383 defer cancel()
3384 mysqlPos, err := sdw.wr.TabletManagerClient().StopSlaveMinimum(shortCtx, sourceTablet.Tablet, vreplicationPos, *remoteActionsTimeout)
3385 if err != nil {
3386@@ -345,7 +346,7 @@ func (sdw *SplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3387 // 3 - ask the master of the destination shard to resume filtered
3388 // replication up to the new list of positions
3389 sdw.wr.Logger().Infof("Restarting master %v until it catches up to %v", sdw.shardInfo.MasterAlias, mysqlPos)
3390- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3391+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:348")
3392 defer cancel()
3393 _, err = sdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StartVReplicationUntil(sdw.sourceShard.Uid, mysqlPos))
3394 if err != nil {
3395@@ -362,13 +363,13 @@ func (sdw *SplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3396 // 4 - wait until the destination tablet is equal or passed
3397 // that master binlog position, and stop its replication.
3398 sdw.wr.Logger().Infof("Waiting for destination tablet %v to catch up to %v", sdw.destinationAlias, masterPos)
3399- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3400+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:365")
3401 defer cancel()
3402 destinationTablet, err := sdw.wr.TopoServer().GetTablet(shortCtx, sdw.destinationAlias)
3403 if err != nil {
3404 return err
3405 }
3406- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3407+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:371")
3408 defer cancel()
3409 if _, err = sdw.wr.TabletManagerClient().StopSlaveMinimum(shortCtx, destinationTablet.Tablet, masterPos, *remoteActionsTimeout); err != nil {
3410 return vterrors.Wrapf(err, "StopSlaveMinimum for %v at %v failed", sdw.destinationAlias, masterPos)
3411@@ -377,7 +378,7 @@ func (sdw *SplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3412
3413 // 5 - restart filtered replication on destination master
3414 sdw.wr.Logger().Infof("Restarting filtered replication on master %v", sdw.shardInfo.MasterAlias)
3415- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3416+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:380")
3417 defer cancel()
3418 if _, err = sdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StartVReplication(sdw.sourceShard.Uid)); err != nil {
3419 return vterrors.Wrapf(err, "VReplicationExec(start) failed for %v", sdw.shardInfo.MasterAlias)
3420@@ -400,7 +401,7 @@ func (sdw *SplitDiffWorker) diff(ctx context.Context) error {
3421 wg.Add(1)
3422 go func() {
3423 var err error
3424- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3425+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:403")
3426 sdw.destinationSchemaDefinition, err = sdw.wr.GetSchema(
3427 shortCtx, sdw.destinationAlias, nil /* tables */, sdw.excludeTables, false /* includeViews */)
3428 cancel()
3429@@ -413,7 +414,7 @@ func (sdw *SplitDiffWorker) diff(ctx context.Context) error {
3430 wg.Add(1)
3431 go func() {
3432 var err error
3433- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3434+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff.go:416")
3435 sdw.sourceSchemaDefinition, err = sdw.wr.GetSchema(
3436 shortCtx, sdw.sourceAlias, nil /* tables */, sdw.excludeTables, false /* includeViews */)
3437 cancel()
3438diff --git a/go/vt/worker/split_diff_cmd.go b/go/vt/worker/split_diff_cmd.go
3439index 5ece6f5dc..bd52efae6 100644
3440--- a/go/vt/worker/split_diff_cmd.go
3441+++ b/go/vt/worker/split_diff_cmd.go
3442@@ -25,6 +25,7 @@ import (
3443 "strings"
3444 "sync"
3445
3446+ "vitess.io/vitess/go/context2"
3447 "vitess.io/vitess/go/vt/proto/vtrpc"
3448 "vitess.io/vitess/go/vt/vterrors"
3449
3450@@ -114,7 +115,7 @@ func commandSplitDiff(wi *Instance, wr *wrangler.Wrangler, subFlags *flag.FlagSe
3451 // shardsWithSources returns all the shards that have SourceShards set
3452 // with no Tables list.
3453 func shardsWithSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string]string, error) {
3454- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3455+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff_cmd.go:117")
3456 keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
3457 cancel()
3458 if err != nil {
3459@@ -129,7 +130,7 @@ func shardsWithSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string
3460 wg.Add(1)
3461 go func(keyspace string) {
3462 defer wg.Done()
3463- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3464+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff_cmd.go:132")
3465 shards, err := wr.TopoServer().GetShardNames(shortCtx, keyspace)
3466 cancel()
3467 if err != nil {
3468@@ -140,7 +141,7 @@ func shardsWithSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string
3469 wg.Add(1)
3470 go func(keyspace, shard string) {
3471 defer wg.Done()
3472- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3473+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/split_diff_cmd.go:143")
3474 si, err := wr.TopoServer().GetShard(shortCtx, keyspace, shard)
3475 cancel()
3476 if err != nil {
3477diff --git a/go/vt/worker/tablet_provider.go b/go/vt/worker/tablet_provider.go
3478index 2d42bcb7f..47a7b950b 100644
3479--- a/go/vt/worker/tablet_provider.go
3480+++ b/go/vt/worker/tablet_provider.go
3481@@ -19,6 +19,7 @@ package worker
3482 import (
3483 "fmt"
3484
3485+ "vitess.io/vitess/go/context2"
3486 "vitess.io/vitess/go/vt/vterrors"
3487
3488 "golang.org/x/net/context"
3489@@ -57,7 +58,7 @@ func newSingleTabletProvider(ctx context.Context, ts *topo.Server, alias *topoda
3490 }
3491
3492 func (p *singleTabletProvider) getTablet() (*topodatapb.Tablet, error) {
3493- shortCtx, cancel := context.WithTimeout(p.ctx, *remoteActionsTimeout)
3494+ shortCtx, cancel := context2.WithTimeout(p.ctx, *remoteActionsTimeout, "./go/vt/worker/tablet_provider.go:60")
3495 tablet, err := p.ts.GetTablet(shortCtx, p.alias)
3496 cancel()
3497 if err != nil {
3498diff --git a/go/vt/worker/topo_utils.go b/go/vt/worker/topo_utils.go
3499index 4dcc52a1d..aa7b4a182 100644
3500--- a/go/vt/worker/topo_utils.go
3501+++ b/go/vt/worker/topo_utils.go
3502@@ -22,6 +22,7 @@ import (
3503 "math/rand"
3504 "time"
3505
3506+ "vitess.io/vitess/go/context2"
3507 "vitess.io/vitess/go/vt/vterrors"
3508
3509 "golang.org/x/net/context"
3510@@ -68,7 +69,7 @@ func FindHealthyTablet(ctx context.Context, wr *wrangler.Wrangler, tsc *discover
3511 }
3512
3513 func waitForHealthyTablets(ctx context.Context, wr *wrangler.Wrangler, tsc *discovery.TabletStatsCache, cell, keyspace, shard string, minHealthyRdonlyTablets int, timeout time.Duration, tabletType topodatapb.TabletType) ([]discovery.TabletStats, error) {
3514- busywaitCtx, busywaitCancel := context.WithTimeout(ctx, timeout)
3515+ busywaitCtx, busywaitCancel := context2.WithTimeout(ctx, timeout, "./go/vt/worker/topo_utils.go:71")
3516 defer busywaitCancel()
3517
3518 start := time.Now()
3519@@ -122,7 +123,7 @@ func FindWorkerTablet(ctx context.Context, wr *wrangler.Wrangler, cleaner *wrang
3520 }
3521
3522 wr.Logger().Infof("Changing tablet %v to '%v'", topoproto.TabletAliasString(tabletAlias), topodatapb.TabletType_DRAINED)
3523- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3524+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/topo_utils.go:125")
3525 err = wr.ChangeSlaveType(shortCtx, tabletAlias, topodatapb.TabletType_DRAINED)
3526 cancel()
3527 if err != nil {
3528@@ -131,7 +132,7 @@ func FindWorkerTablet(ctx context.Context, wr *wrangler.Wrangler, cleaner *wrang
3529
3530 ourURL := servenv.ListeningURL.String()
3531 wr.Logger().Infof("Adding tag[worker]=%v to tablet %v", ourURL, topoproto.TabletAliasString(tabletAlias))
3532- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3533+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/topo_utils.go:134")
3534 _, err = wr.TopoServer().UpdateTabletFields(shortCtx, tabletAlias, func(tablet *topodatapb.Tablet) error {
3535 if tablet.Tags == nil {
3536 tablet.Tags = make(map[string]string)
3537@@ -154,7 +155,7 @@ func FindWorkerTablet(ctx context.Context, wr *wrangler.Wrangler, cleaner *wrang
3538 wrangler.RecordChangeSlaveTypeAction(cleaner, tabletAlias, topodatapb.TabletType_DRAINED, tabletType)
3539
3540 // We refresh the destination vttablet reloads the worker URL when it reloads the tablet.
3541- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3542+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/topo_utils.go:157")
3543 wr.RefreshTabletState(shortCtx, tabletAlias)
3544 if err != nil {
3545 return nil, err
3546diff --git a/go/vt/worker/utils_test.go b/go/vt/worker/utils_test.go
3547index 98bdd416e..6dbe8a9dc 100644
3548--- a/go/vt/worker/utils_test.go
3549+++ b/go/vt/worker/utils_test.go
3550@@ -22,6 +22,7 @@ import (
3551
3552 "golang.org/x/net/context"
3553
3554+ "vitess.io/vitess/go/context2"
3555 "vitess.io/vitess/go/mysql/fakesqldb"
3556 "vitess.io/vitess/go/sqltypes"
3557 "vitess.io/vitess/go/vt/topo"
3558@@ -39,7 +40,7 @@ import (
3559 func runCommand(t *testing.T, wi *Instance, wr *wrangler.Wrangler, args []string) error {
3560 // Limit the scope of the context e.g. to implicitly terminate stray Go
3561 // routines.
3562- ctx, cancel := context.WithCancel(context.Background())
3563+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/worker/utils_test.go:42")
3564 defer cancel()
3565
3566 worker, done, err := wi.RunCommand(ctx, args, wr, false /* runFromCli */)
3567diff --git a/go/vt/worker/vertical_split_clone_cmd.go b/go/vt/worker/vertical_split_clone_cmd.go
3568index 7045fb3e6..0298ca959 100644
3569--- a/go/vt/worker/vertical_split_clone_cmd.go
3570+++ b/go/vt/worker/vertical_split_clone_cmd.go
3571@@ -25,6 +25,7 @@ import (
3572 "strings"
3573 "sync"
3574
3575+ "vitess.io/vitess/go/context2"
3576 "vitess.io/vitess/go/vt/proto/topodata"
3577 "vitess.io/vitess/go/vt/vterrors"
3578
3579@@ -152,7 +153,7 @@ func commandVerticalSplitClone(wi *Instance, wr *wrangler.Wrangler, subFlags *fl
3580 // keyspacesWithServedFrom returns all the keyspaces that have ServedFrom set
3581 // to one value.
3582 func keyspacesWithServedFrom(ctx context.Context, wr *wrangler.Wrangler) ([]string, error) {
3583- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3584+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_clone_cmd.go:155")
3585 keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
3586 cancel()
3587 if err != nil {
3588@@ -167,7 +168,7 @@ func keyspacesWithServedFrom(ctx context.Context, wr *wrangler.Wrangler) ([]stri
3589 wg.Add(1)
3590 go func(keyspace string) {
3591 defer wg.Done()
3592- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3593+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_clone_cmd.go:170")
3594 ki, err := wr.TopoServer().GetKeyspace(shortCtx, keyspace)
3595 cancel()
3596 if err != nil {
3597@@ -288,7 +289,7 @@ func interactiveVerticalSplitClone(ctx context.Context, wi *Instance, wr *wrangl
3598 }
3599
3600 // Figure out the shard
3601- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3602+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_clone_cmd.go:291")
3603 shardMap, err := wr.TopoServer().FindAllShardsInKeyspace(shortCtx, keyspace)
3604 cancel()
3605 if err != nil {
3606diff --git a/go/vt/worker/vertical_split_diff.go b/go/vt/worker/vertical_split_diff.go
3607index fb5a8e3a0..a99c8ae95 100644
3608--- a/go/vt/worker/vertical_split_diff.go
3609+++ b/go/vt/worker/vertical_split_diff.go
3610@@ -21,6 +21,7 @@ import (
3611 "html/template"
3612 "sync"
3613
3614+ "vitess.io/vitess/go/context2"
3615 "vitess.io/vitess/go/vt/vterrors"
3616
3617 "golang.org/x/net/context"
3618@@ -261,7 +262,7 @@ func (vsdw *VerticalSplitDiffWorker) findTargets(ctx context.Context) error {
3619 func (vsdw *VerticalSplitDiffWorker) synchronizeReplication(ctx context.Context) error {
3620 vsdw.SetState(WorkerStateSyncReplication)
3621
3622- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3623+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:264")
3624 defer cancel()
3625 masterInfo, err := vsdw.wr.TopoServer().GetTablet(shortCtx, vsdw.shardInfo.MasterAlias)
3626 if err != nil {
3627@@ -272,7 +273,7 @@ func (vsdw *VerticalSplitDiffWorker) synchronizeReplication(ctx context.Context)
3628
3629 // 1 - stop the master binlog replication, get its current position
3630 vsdw.wr.Logger().Infof("Stopping master binlog replication on %v", topoproto.TabletAliasString(vsdw.shardInfo.MasterAlias))
3631- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3632+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:275")
3633 defer cancel()
3634 _, err = vsdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StopVReplication(ss.Uid, "for split diff"))
3635 if err != nil {
3636@@ -291,7 +292,7 @@ func (vsdw *VerticalSplitDiffWorker) synchronizeReplication(ctx context.Context)
3637
3638 // stop replication
3639 vsdw.wr.Logger().Infof("Stopping slave %v at a minimum of %v", topoproto.TabletAliasString(vsdw.sourceAlias), vreplicationPos)
3640- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3641+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:294")
3642 defer cancel()
3643 sourceTablet, err := vsdw.wr.TopoServer().GetTablet(shortCtx, vsdw.sourceAlias)
3644 if err != nil {
3645@@ -309,7 +310,7 @@ func (vsdw *VerticalSplitDiffWorker) synchronizeReplication(ctx context.Context)
3646 // 3 - ask the master of the destination shard to resume filtered
3647 // replication up to the new list of positions
3648 vsdw.wr.Logger().Infof("Restarting master %v until it catches up to %v", topoproto.TabletAliasString(vsdw.shardInfo.MasterAlias), mysqlPos)
3649- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3650+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:312")
3651 defer cancel()
3652 _, err = vsdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StartVReplicationUntil(ss.Uid, mysqlPos))
3653 if err != nil {
3654@@ -326,13 +327,13 @@ func (vsdw *VerticalSplitDiffWorker) synchronizeReplication(ctx context.Context)
3655 // 4 - wait until the destination tablet is equal or passed
3656 // that master binlog position, and stop its replication.
3657 vsdw.wr.Logger().Infof("Waiting for destination tablet %v to catch up to %v", topoproto.TabletAliasString(vsdw.destinationAlias), masterPos)
3658- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3659+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:329")
3660 defer cancel()
3661 destinationTablet, err := vsdw.wr.TopoServer().GetTablet(shortCtx, vsdw.destinationAlias)
3662 if err != nil {
3663 return err
3664 }
3665- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3666+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:335")
3667 defer cancel()
3668 _, err = vsdw.wr.TabletManagerClient().StopSlaveMinimum(shortCtx, destinationTablet.Tablet, masterPos, *remoteActionsTimeout)
3669 if err != nil {
3670@@ -342,7 +343,7 @@ func (vsdw *VerticalSplitDiffWorker) synchronizeReplication(ctx context.Context)
3671
3672 // 5 - restart filtered replication on destination master
3673 vsdw.wr.Logger().Infof("Restarting filtered replication on master %v", topoproto.TabletAliasString(vsdw.shardInfo.MasterAlias))
3674- shortCtx, cancel = context.WithTimeout(ctx, *remoteActionsTimeout)
3675+ shortCtx, cancel = context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:345")
3676 defer cancel()
3677 if _, err = vsdw.wr.TabletManagerClient().VReplicationExec(shortCtx, masterInfo.Tablet, binlogplayer.StartVReplication(ss.Uid)); err != nil {
3678 return vterrors.Wrapf(err, "VReplicationExec(start) failed for %v", vsdw.shardInfo.MasterAlias)
3679@@ -365,7 +366,7 @@ func (vsdw *VerticalSplitDiffWorker) diff(ctx context.Context) error {
3680 wg.Add(1)
3681 go func() {
3682 var err error
3683- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3684+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:368")
3685 vsdw.destinationSchemaDefinition, err = vsdw.wr.GetSchema(
3686 shortCtx, vsdw.destinationAlias, vsdw.shardInfo.SourceShards[0].Tables, nil /* excludeTables */, false /* includeViews */)
3687 cancel()
3688@@ -378,7 +379,7 @@ func (vsdw *VerticalSplitDiffWorker) diff(ctx context.Context) error {
3689 wg.Add(1)
3690 go func() {
3691 var err error
3692- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3693+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff.go:381")
3694 vsdw.sourceSchemaDefinition, err = vsdw.wr.GetSchema(
3695 shortCtx, vsdw.sourceAlias, vsdw.shardInfo.SourceShards[0].Tables, nil /* excludeTables */, false /* includeViews */)
3696 cancel()
3697diff --git a/go/vt/worker/vertical_split_diff_cmd.go b/go/vt/worker/vertical_split_diff_cmd.go
3698index e4cfd4d34..cc997b9d1 100644
3699--- a/go/vt/worker/vertical_split_diff_cmd.go
3700+++ b/go/vt/worker/vertical_split_diff_cmd.go
3701@@ -24,6 +24,7 @@ import (
3702 "strconv"
3703 "sync"
3704
3705+ "vitess.io/vitess/go/context2"
3706 "vitess.io/vitess/go/vt/vterrors"
3707
3708 "golang.org/x/net/context"
3709@@ -101,7 +102,7 @@ func commandVerticalSplitDiff(wi *Instance, wr *wrangler.Wrangler, subFlags *fla
3710 // shardsWithTablesSources returns all the shards that have SourceShards set
3711 // to one value, with an array of Tables.
3712 func shardsWithTablesSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[string]string, error) {
3713- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3714+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff_cmd.go:104")
3715 keyspaces, err := wr.TopoServer().GetKeyspaces(shortCtx)
3716 cancel()
3717 if err != nil {
3718@@ -116,7 +117,7 @@ func shardsWithTablesSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[
3719 wg.Add(1)
3720 go func(keyspace string) {
3721 defer wg.Done()
3722- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3723+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff_cmd.go:119")
3724 shards, err := wr.TopoServer().GetShardNames(shortCtx, keyspace)
3725 cancel()
3726 if err != nil {
3727@@ -127,7 +128,7 @@ func shardsWithTablesSources(ctx context.Context, wr *wrangler.Wrangler) ([]map[
3728 wg.Add(1)
3729 go func(keyspace, shard string) {
3730 defer wg.Done()
3731- shortCtx, cancel := context.WithTimeout(ctx, *remoteActionsTimeout)
3732+ shortCtx, cancel := context2.WithTimeout(ctx, *remoteActionsTimeout, "./go/vt/worker/vertical_split_diff_cmd.go:130")
3733 si, err := wr.TopoServer().GetShard(shortCtx, keyspace, shard)
3734 cancel()
3735 if err != nil {
3736diff --git a/go/vt/worker/vtworkerclienttest/client_testsuite.go b/go/vt/worker/vtworkerclienttest/client_testsuite.go
3737index b5ff551d5..1ac4b3bff 100644
3738--- a/go/vt/worker/vtworkerclienttest/client_testsuite.go
3739+++ b/go/vt/worker/vtworkerclienttest/client_testsuite.go
3740@@ -34,6 +34,7 @@ import (
3741
3742 "golang.org/x/net/context"
3743
3744+ "vitess.io/vitess/go/context2"
3745 "vitess.io/vitess/go/vt/logutil"
3746 "vitess.io/vitess/go/vt/topo/memorytopo"
3747 "vitess.io/vitess/go/vt/vterrors"
3748@@ -123,7 +124,7 @@ func runVtworkerCommand(client vtworkerclient.Client, args []string) error {
3749 func commandErrorsBecauseBusy(t *testing.T, client vtworkerclient.Client, serverSideCancelation bool) {
3750 // Run the vtworker "Block" command which blocks until we cancel the context.
3751 var wg sync.WaitGroup
3752- ctx, cancel := context.WithCancel(context.Background())
3753+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/worker/vtworkerclienttest/client_testsuite.go:126")
3754 // blockCommandStarted will be closed after we're sure that vtworker is
3755 // running the "Block" command.
3756 blockCommandStarted := make(chan struct{})
3757diff --git a/go/vt/workflow/manager.go b/go/vt/workflow/manager.go
3758index f3f94d39f..c4529a8bd 100644
3759--- a/go/vt/workflow/manager.go
3760+++ b/go/vt/workflow/manager.go
3761@@ -26,6 +26,7 @@ import (
3762 gouuid "github.com/pborman/uuid"
3763 "golang.org/x/net/context"
3764
3765+ "vitess.io/vitess/go/context2"
3766 "vitess.io/vitess/go/vt/log"
3767 "vitess.io/vitess/go/vt/topo"
3768
3769@@ -352,7 +353,7 @@ func (m *Manager) Start(ctx context.Context, uuid string) error {
3770 func (m *Manager) runWorkflow(rw *runningWorkflow) {
3771 // Create a context to run it.
3772 var ctx context.Context
3773- ctx, rw.cancel = context.WithCancel(m.ctx)
3774+ ctx, rw.cancel = context2.WithCancel(m.ctx, "./go/vt/workflow/manager.go:355")
3775
3776 // And run it in the background.
3777 go m.executeWorkflowRun(ctx, rw)
3778@@ -589,7 +590,7 @@ func AvailableFactories() map[string]bool {
3779
3780 // StartManager starts a manager. This function should only be used for tests purposes.
3781 func StartManager(m *Manager) (*sync.WaitGroup, context.Context, context.CancelFunc) {
3782- ctx, cancel := context.WithCancel(context.Background())
3783+ ctx, cancel := context2.WithCancel(context.Background(), "./go/vt/workflow/manager.go:592")
3784 wg := &sync.WaitGroup{}
3785 wg.Add(1)
3786 go func() {
3787diff --git a/go/vt/wrangler/cleaner.go b/go/vt/wrangler/cleaner.go
3788index e40b9c08d..837d20a88 100644
3789--- a/go/vt/wrangler/cleaner.go
3790+++ b/go/vt/wrangler/cleaner.go
3791@@ -22,6 +22,7 @@ import (
3792 "time"
3793
3794 "golang.org/x/net/context"
3795+ "vitess.io/vitess/go/context2"
3796 "vitess.io/vitess/go/vt/concurrency"
3797 "vitess.io/vitess/go/vt/topo"
3798 "vitess.io/vitess/go/vt/topo/topoproto"
3799@@ -96,7 +97,7 @@ type cleanUpHelper struct {
3800 // basis. They are then serialized on each target.
3801 func (cleaner *Cleaner) CleanUp(wr *Wrangler) error {
3802 // we use a background context so we're not dependent on the original context timeout
3803- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
3804+ ctx, cancel := context2.WithTimeout(context.Background(), 5*time.Minute, "./go/vt/wrangler/cleaner.go:99")
3805 actionMap := make(map[string]*cleanUpHelper)
3806 rec := concurrency.AllErrorRecorder{}
3807 cleaner.mu.Lock()
3808diff --git a/go/vt/wrangler/fake_tablet_test.go b/go/vt/wrangler/fake_tablet_test.go
3809index 85adabf6c..fc5ada634 100644
3810--- a/go/vt/wrangler/fake_tablet_test.go
3811+++ b/go/vt/wrangler/fake_tablet_test.go
3812@@ -25,6 +25,7 @@ import (
3813
3814 "golang.org/x/net/context"
3815 "google.golang.org/grpc"
3816+ "vitess.io/vitess/go/context2"
3817 "vitess.io/vitess/go/mysql/fakesqldb"
3818 "vitess.io/vitess/go/vt/mysqlctl/fakemysqldaemon"
3819 querypb "vitess.io/vitess/go/vt/proto/query"
3820@@ -183,7 +184,7 @@ func (ft *fakeTablet) StartActionLoop(t *testing.T, wr *Wrangler) {
3821 step := 10 * time.Millisecond
3822 c := tmclient.NewTabletManagerClient()
3823 for timeout >= 0 {
3824- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
3825+ ctx, cancel := context2.WithTimeout(context.Background(), 1*time.Second, "./go/vt/wrangler/fake_tablet_test.go:186")
3826 err := c.Ping(ctx, ft.Agent.Tablet())
3827 cancel()
3828 if err == nil {
3829diff --git a/go/vt/wrangler/keyspace.go b/go/vt/wrangler/keyspace.go
3830index b31f20d83..6d64cb55b 100644
3831--- a/go/vt/wrangler/keyspace.go
3832+++ b/go/vt/wrangler/keyspace.go
3833@@ -25,6 +25,7 @@ import (
3834 "time"
3835
3836 "golang.org/x/net/context"
3837+ "vitess.io/vitess/go/context2"
3838 "vitess.io/vitess/go/event"
3839 "vitess.io/vitess/go/sqltypes"
3840 "vitess.io/vitess/go/vt/binlog/binlogplayer"
3841@@ -495,7 +496,7 @@ func (wr *Wrangler) waitForFilteredReplication(ctx context.Context, sourcePositi
3842 wg.Add(1)
3843 go func(si *topo.ShardInfo) {
3844 defer wg.Done()
3845- ctx, cancel := context.WithTimeout(ctx, waitTime)
3846+ ctx, cancel := context2.WithTimeout(ctx, waitTime, "./go/vt/wrangler/keyspace.go:498")
3847 defer cancel()
3848
3849 var pos string
3850@@ -1231,7 +1232,7 @@ func (wr *Wrangler) replicaMigrateServedFrom(ctx context.Context, ki *topo.Keysp
3851 // replication and starts accepting writes
3852 func (wr *Wrangler) masterMigrateServedFrom(ctx context.Context, ki *topo.KeyspaceInfo, sourceShard *topo.ShardInfo, destinationShard *topo.ShardInfo, tables []string, ev *events.MigrateServedFrom, filteredReplicationWaitTime time.Duration) error {
3853 // Read the data we need
3854- ctx, cancel := context.WithTimeout(ctx, filteredReplicationWaitTime)
3855+ ctx, cancel := context2.WithTimeout(ctx, filteredReplicationWaitTime, "./go/vt/wrangler/keyspace.go:1234")
3856 defer cancel()
3857 sourceMasterTabletInfo, err := wr.ts.GetTablet(ctx, sourceShard.MasterAlias)
3858 if err != nil {
3859@@ -1356,7 +1357,7 @@ func (wr *Wrangler) RefreshTabletsByShard(ctx context.Context, si *topo.ShardInf
3860 // Setting an upper bound timeout to fail faster in case of an error.
3861 // Using 60 seconds because RefreshState should not take more than 30 seconds.
3862 // (RefreshState will restart the tablet's QueryService and most time will be spent on the shutdown, i.e. waiting up to 30 seconds on transactions (see Config.TransactionTimeout)).
3863- ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
3864+ ctx, cancel := context2.WithTimeout(ctx, 60*time.Second, "./go/vt/wrangler/keyspace.go:1359")
3865 if err := wr.tmc.RefreshState(ctx, ti.Tablet); err != nil {
3866 wr.Logger().Warningf("RefreshTabletsByShard: failed to refresh %v: %v", ti.AliasString(), err)
3867 }
3868diff --git a/go/vt/wrangler/migrater.go b/go/vt/wrangler/migrater.go
3869index 0f5c368a2..91c7ed462 100644
3870--- a/go/vt/wrangler/migrater.go
3871+++ b/go/vt/wrangler/migrater.go
3872@@ -28,6 +28,7 @@ import (
3873
3874 "github.com/golang/protobuf/proto"
3875 "golang.org/x/net/context"
3876+ "vitess.io/vitess/go/context2"
3877 "vitess.io/vitess/go/sqltypes"
3878 "vitess.io/vitess/go/sync2"
3879 "vitess.io/vitess/go/vt/binlog/binlogplayer"
3880@@ -505,7 +506,7 @@ func (mi *migrater) changeTableSourceWrites(ctx context.Context, access accessTy
3881 }
3882
3883 func (mi *migrater) waitForCatchup(ctx context.Context, filteredReplicationWaitTime time.Duration) error {
3884- ctx, cancel := context.WithTimeout(ctx, filteredReplicationWaitTime)
3885+ ctx, cancel := context2.WithTimeout(ctx, filteredReplicationWaitTime, "./go/vt/wrangler/migrater.go:508")
3886 defer cancel()
3887
3888 var mu sync.Mutex
3889diff --git a/go/vt/wrangler/reparent.go b/go/vt/wrangler/reparent.go
3890index 06b99e21f..9e752e1f1 100644
3891--- a/go/vt/wrangler/reparent.go
3892+++ b/go/vt/wrangler/reparent.go
3893@@ -26,6 +26,7 @@ import (
3894 "sync"
3895 "time"
3896
3897+ "vitess.io/vitess/go/context2"
3898 "vitess.io/vitess/go/event"
3899 "vitess.io/vitess/go/mysql"
3900 "vitess.io/vitess/go/sqlescape"
3901@@ -206,7 +207,7 @@ func (wr *Wrangler) initShardMasterLocked(ctx context.Context, ev *events.Repare
3902 // at a wrong replication spot.
3903
3904 // Create a context for the following RPCs that respects waitSlaveTimeout
3905- resetCtx, resetCancel := context.WithTimeout(ctx, waitSlaveTimeout)
3906+ resetCtx, resetCancel := context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/reparent.go:209")
3907 defer resetCancel()
3908
3909 event.DispatchUpdate(ev, "resetting replication on all tablets")
3910@@ -249,7 +250,7 @@ func (wr *Wrangler) initShardMasterLocked(ctx context.Context, ev *events.Repare
3911
3912 // Create a cancelable context for the following RPCs.
3913 // If error conditions happen, we can cancel all outgoing RPCs.
3914- replCtx, replCancel := context.WithTimeout(ctx, waitSlaveTimeout)
3915+ replCtx, replCancel := context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/reparent.go:252")
3916 defer replCancel()
3917
3918 // Now tell the new master to insert the reparent_journal row,
3919@@ -414,7 +415,7 @@ func (wr *Wrangler) plannedReparentShardLocked(ctx context.Context, ev *events.R
3920 ev.OldMaster = *oldMasterTabletInfo.Tablet
3921
3922 // create a new context for the short running remote operations
3923- remoteCtx, remoteCancel := context.WithTimeout(ctx, *topo.RemoteOperationTimeout)
3924+ remoteCtx, remoteCancel := context2.WithTimeout(ctx, *topo.RemoteOperationTimeout, "./go/vt/wrangler/reparent.go:417")
3925 defer remoteCancel()
3926
3927 // Demote the current master, get its replication position
3928@@ -425,7 +426,7 @@ func (wr *Wrangler) plannedReparentShardLocked(ctx context.Context, ev *events.R
3929 return fmt.Errorf("old master tablet %v DemoteMaster failed: %v", topoproto.TabletAliasString(shardInfo.MasterAlias), err)
3930 }
3931
3932- remoteCtx, remoteCancel = context.WithTimeout(ctx, waitSlaveTimeout)
3933+ remoteCtx, remoteCancel = context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/reparent.go:428")
3934 defer remoteCancel()
3935
3936 // Wait on the master-elect tablet until it reaches that position,
3937@@ -436,7 +437,7 @@ func (wr *Wrangler) plannedReparentShardLocked(ctx context.Context, ev *events.R
3938 if err != nil || (ctx.Err() != nil && ctx.Err() == context.DeadlineExceeded) {
3939 remoteCancel()
3940 // if this fails it is not enough to return an error. we should rollback all the changes made by DemoteMaster
3941- remoteCtx, remoteCancel = context.WithTimeout(ctx, *topo.RemoteOperationTimeout)
3942+ remoteCtx, remoteCancel = context2.WithTimeout(ctx, *topo.RemoteOperationTimeout, "./go/vt/wrangler/reparent.go:439")
3943 defer remoteCancel()
3944 if err1 := wr.tmc.UndoDemoteMaster(remoteCtx, oldMasterTabletInfo.Tablet); err1 != nil {
3945 log.Warningf("Encountered error %v while trying to undo DemoteMaster", err1)
3946@@ -451,7 +452,7 @@ func (wr *Wrangler) plannedReparentShardLocked(ctx context.Context, ev *events.R
3947
3948 // Create a cancelable context for the following RPCs.
3949 // If error conditions happen, we can cancel all outgoing RPCs.
3950- replCtx, replCancel := context.WithTimeout(ctx, waitSlaveTimeout)
3951+ replCtx, replCancel := context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/reparent.go:454")
3952 defer replCancel()
3953
3954 // Go through all the tablets:
3955@@ -533,7 +534,7 @@ func (maxPosSearch *maxReplPosSearch) processTablet(tablet *topodatapb.Tablet) {
3956 defer maxPosSearch.waitGroup.Done()
3957 maxPosSearch.wrangler.logger.Infof("getting replication position from %v", topoproto.TabletAliasString(tablet.Alias))
3958
3959- slaveStatusCtx, cancelSlaveStatus := context.WithTimeout(maxPosSearch.ctx, maxPosSearch.waitSlaveTimeout)
3960+ slaveStatusCtx, cancelSlaveStatus := context2.WithTimeout(maxPosSearch.ctx, maxPosSearch.waitSlaveTimeout, "./go/vt/wrangler/reparent.go:536")
3961 defer cancelSlaveStatus()
3962
3963 status, err := maxPosSearch.wrangler.tmc.SlaveStatus(slaveStatusCtx, tablet)
3964@@ -668,7 +669,7 @@ func (wr *Wrangler) emergencyReparentShardLocked(ctx context.Context, ev *events
3965 ev.OldMaster = *oldMasterTabletInfo.Tablet
3966 wr.logger.Infof("deleting old master %v", shardInfoMasterAliasStr)
3967
3968- ctx, cancel := context.WithTimeout(ctx, waitSlaveTimeout)
3969+ ctx, cancel := context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/reparent.go:671")
3970 defer cancel()
3971
3972 if err := topotools.DeleteTablet(ctx, wr.ts, oldMasterTabletInfo.Tablet); err != nil {
3973@@ -688,7 +689,7 @@ func (wr *Wrangler) emergencyReparentShardLocked(ctx context.Context, ev *events
3974 go func(alias string, tabletInfo *topo.TabletInfo) {
3975 defer wg.Done()
3976 wr.logger.Infof("getting replication position from %v", alias)
3977- ctx, cancel := context.WithTimeout(ctx, waitSlaveTimeout)
3978+ ctx, cancel := context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/reparent.go:691")
3979 defer cancel()
3980 rp, err := wr.tmc.StopReplicationAndGetStatus(ctx, tabletInfo.Tablet)
3981 if err != nil {
3982@@ -744,7 +745,7 @@ func (wr *Wrangler) emergencyReparentShardLocked(ctx context.Context, ev *events
3983
3984 // Create a cancelable context for the following RPCs.
3985 // If error conditions happen, we can cancel all outgoing RPCs.
3986- replCtx, replCancel := context.WithCancel(ctx)
3987+ replCtx, replCancel := context2.WithCancel(ctx, "./go/vt/wrangler/reparent.go:747")
3988 defer replCancel()
3989
3990 // Reset replication on all slaves to point to the new master, and
3991diff --git a/go/vt/wrangler/schema.go b/go/vt/wrangler/schema.go
3992index fd0411727..ec9201196 100644
3993--- a/go/vt/wrangler/schema.go
3994+++ b/go/vt/wrangler/schema.go
3995@@ -26,6 +26,7 @@ import (
3996
3997 "golang.org/x/net/context"
3998
3999+ "vitess.io/vitess/go/context2"
4000 "vitess.io/vitess/go/sqltypes"
4001 "vitess.io/vitess/go/sync2"
4002 "vitess.io/vitess/go/vt/concurrency"
4003@@ -359,7 +360,7 @@ func (wr *Wrangler) CopySchemaShard(ctx context.Context, sourceTabletAlias *topo
4004
4005 // Notify slaves to reload schema. This is best-effort.
4006 concurrency := sync2.NewSemaphore(10, 0)
4007- reloadCtx, cancel := context.WithTimeout(ctx, waitSlaveTimeout)
4008+ reloadCtx, cancel := context2.WithTimeout(ctx, waitSlaveTimeout, "./go/vt/wrangler/schema.go:362")
4009 defer cancel()
4010 wr.ReloadSchemaShard(reloadCtx, destKeyspace, destShard, destMasterPos, concurrency, true /* includeMaster */)
4011 return nil
4012@@ -435,7 +436,7 @@ func (wr *Wrangler) applySQLShard(ctx context.Context, tabletInfo *topo.TabletIn
4013 if err != nil {
4014 return fmt.Errorf("fillStringTemplate failed: %v", err)
4015 }
4016- ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
4017+ ctx, cancel := context2.WithTimeout(ctx, 30*time.Second, "./go/vt/wrangler/schema.go:438")
4018 defer cancel()
4019 // Need to make sure that we enable binlog, since we're only applying the statement on masters.
4020 _, err = wr.tmc.ExecuteFetchAsDba(ctx, tabletInfo.Tablet, false, []byte(filledChange), 0, false, reloadSchema)
4021diff --git a/go/vt/wrangler/testlib/fake_tablet.go b/go/vt/wrangler/testlib/fake_tablet.go
4022index 75766e27d..557ee2ad0 100644
4023--- a/go/vt/wrangler/testlib/fake_tablet.go
4024+++ b/go/vt/wrangler/testlib/fake_tablet.go
4025@@ -30,6 +30,7 @@ import (
4026 "golang.org/x/net/context"
4027 "google.golang.org/grpc"
4028
4029+ "vitess.io/vitess/go/context2"
4030 "vitess.io/vitess/go/mysql/fakesqldb"
4031 "vitess.io/vitess/go/vt/mysqlctl/fakemysqldaemon"
4032 "vitess.io/vitess/go/vt/topo"
4033@@ -206,7 +207,7 @@ func (ft *FakeTablet) StartActionLoop(t *testing.T, wr *wrangler.Wrangler) {
4034 step := 10 * time.Millisecond
4035 c := tmclient.NewTabletManagerClient()
4036 for timeout >= 0 {
4037- ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
4038+ ctx, cancel := context2.WithTimeout(context.Background(), 1*time.Second, "./go/vt/wrangler/testlib/fake_tablet.go:209")
4039 err := c.Ping(ctx, ft.Agent.Tablet())
4040 cancel()
4041 if err == nil {