Skip to content

Commit

Permalink
kv: init heartbeat txn log tag later
Browse files Browse the repository at this point in the history
At init() time, the txn proto has not been populated yet.
Found while investigating #39652.

Release note: None
  • Loading branch information
tbg committed Aug 14, 2019
1 parent 3110746 commit dc3686f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/kv/txn_interceptor_heartbeater.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit dc3686f

Please sign in to comment.