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