Skip to content

Commit

Permalink
Merge #81734 #81857
Browse files Browse the repository at this point in the history
81734: ppc64le - fix test failures of TestBoundingBoxFromGeomT/GeographyType r=otan a=prashantkhoje

Allow floating point approximation within an epsilon
Fixes #81733 

81857: sql/catalog/lease: add some event logging around lease acquisition r=ajwerner a=ajwerner

Before this, there was a black hole of time when we were acquiring a lease.
The singleflight prevents tracing of the actual acquisition.

Release note: None

Co-authored-by: Prashant Khoje <[email protected]>
Co-authored-by: Prashant Khoje <[email protected]>
Co-authored-by: Andrew Werner <[email protected]>
  • Loading branch information
4 people committed May 27, 2022
3 parents 78cd75f + 78dd74f + c1b3f2e commit 1047fb0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions pkg/geo/bbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package geo

import (
"fmt"
"math"
"strconv"
"testing"

Expand Down Expand Up @@ -184,6 +185,22 @@ func TestBoundingBoxFromGeomT(t *testing.T) {
t.Run(fmt.Sprintf("%s: %#v", tc.soType, tc.g), func(t *testing.T) {
bbox, err := boundingBoxFromGeomT(tc.g, tc.soType)
require.NoError(t, err)
// If bbox is within a small epsilon of expected, use the same values.
if bbox != nil && tc.expected != nil {
const epsilon = 0.000001
if math.Abs(bbox.LoX-tc.expected.LoX) < epsilon {
bbox.LoX = tc.expected.LoX
}
if math.Abs(bbox.HiX-tc.expected.HiX) < epsilon {
bbox.HiX = tc.expected.HiX
}
if math.Abs(bbox.LoY-tc.expected.LoY) < epsilon {
bbox.LoY = tc.expected.LoY
}
if math.Abs(bbox.HiY-tc.expected.HiY) < epsilon {
bbox.HiY = tc.expected.HiY
}
}
require.Equal(t, tc.expected, bbox)
})
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/sql/catalog/lease/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@ func (m *Manager) AcquireFreshestFromStore(ctx context.Context, id descpb.ID) er
// The boolean returned is true if this call was actually responsible for the
// lease acquisition.
func acquireNodeLease(ctx context.Context, m *Manager, id descpb.ID) (bool, error) {
start := timeutil.Now()
log.VEventf(ctx, 2, "acquiring lease for descriptor %d", id)
var toRelease *storedLease
resultChan, didAcquire := m.storage.group.DoChan(fmt.Sprintf("acquire%d", id), func() (interface{}, error) {
// Note that we use a new `context` here to avoid a situation where a cancellation
Expand Down Expand Up @@ -516,6 +518,7 @@ func acquireNodeLease(ctx context.Context, m *Manager, id descpb.ID) (bool, erro
return false, result.Err
}
}
log.VEventf(ctx, 2, "acquired lease for descriptor %d, took %v", id, timeutil.Since(start))
return didAcquire, nil
}

Expand Down

0 comments on commit 1047fb0

Please sign in to comment.