From dc3686f79b3750500efaff7092c81a3e5ce6d02c Mon Sep 17 00:00:00 2001 From: Tobias Schottdorf Date: Wed, 14 Aug 2019 11:26:56 +0200 Subject: [PATCH] kv: init heartbeat txn log tag later At init() time, the txn proto has not been populated yet. Found while investigating #39652. Release note: None --- pkg/kv/txn_interceptor_heartbeater.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/kv/txn_interceptor_heartbeater.go b/pkg/kv/txn_interceptor_heartbeater.go index 5f7dc1d0455f..7c77fe4d568a 100644 --- a/pkg/kv/txn_interceptor_heartbeater.go +++ b/pkg/kv/txn_interceptor_heartbeater.go @@ -115,7 +115,6 @@ func (h *txnHeartbeater) init( asyncAbortCallbackLocked func(context.Context), ) { h.AmbientContext = ac - h.AmbientContext.AddLogTag("txn-hb", txn.Short()) h.stopper = stopper h.clock = clock h.heartbeatInterval = heartbeatInterval @@ -208,6 +207,9 @@ func (h *txnHeartbeater) startHeartbeatLoopLocked(ctx context.Context) error { log.VEventf(ctx, 2, "coordinator spawns heartbeat loop") h.mu.loopStarted = true h.mu.txnEnd = make(chan struct{}) + // NB: we can't do this in init() because the txn isn't populated yet then + // (it's zero). + h.AmbientContext.AddLogTag("txn-hb", h.mu.txn.Short()) // Create a new context so that the heartbeat loop doesn't inherit the // caller's cancelation.