From d1dfefca407c31d0222904d05fcc9d5a29c56956 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Fri, 21 Dec 2018 21:45:46 -0500 Subject: [PATCH] storage/spanlatch: pass snapshot by reference to wait This does not escape. Release note: None --- pkg/storage/spanlatch/manager.go | 4 ++-- pkg/storage/spanlatch/manager_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/storage/spanlatch/manager.go b/pkg/storage/spanlatch/manager.go index 8ee9df8c67e7..b43a2f82114f 100644 --- a/pkg/storage/spanlatch/manager.go +++ b/pkg/storage/spanlatch/manager.go @@ -208,7 +208,7 @@ func (m *Manager) Acquire( lg, snap := m.sequence(spans, ts) defer snap.close() - err := m.wait(ctx, lg, snap) + err := m.wait(ctx, lg, &snap) if err != nil { m.Release(lg) return nil, err @@ -335,7 +335,7 @@ func ifGlobal(ts hlc.Timestamp, s spanset.SpanScope) hlc.Timestamp { // wait waits for all interfering latches in the provided snapshot to complete // before returning. -func (m *Manager) wait(ctx context.Context, lg *Guard, snap snapshot) error { +func (m *Manager) wait(ctx context.Context, lg *Guard, snap *snapshot) error { timer := timeutil.NewTimer() timer.Reset(base.SlowRequestThreshold) defer timer.Stop() diff --git a/pkg/storage/spanlatch/manager_test.go b/pkg/storage/spanlatch/manager_test.go index 5b80d071036d..29c16a1a8a11 100644 --- a/pkg/storage/spanlatch/manager_test.go +++ b/pkg/storage/spanlatch/manager_test.go @@ -104,7 +104,7 @@ func (m *Manager) MustAcquireChCtx( ch := make(chan *Guard) lg, snap := m.sequence(spans, ts) go func() { - err := m.wait(ctx, lg, snap) + err := m.wait(ctx, lg, &snap) if err != nil { m.Release(lg) lg = nil