mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
attempt to reduce the scope of the Rlock for mutex check
I have not convinced myself that this is safe yet (particularly the change to field.go, I think the view change is likely fine). It does seem to stop the issue... I want to see if tests run in CI.
This commit is contained in:
parent
d7580118ed
commit
7985d1468d
2 changed files with 8 additions and 3 deletions
7
field.go
7
field.go
|
|
@ -1235,9 +1235,14 @@ func (f *Field) MutexCheck(ctx context.Context, qcx *Qcx, details bool, limit in
|
|||
if f.Type() != FieldTypeMutex {
|
||||
return nil, errors.New("mutex check only valid for mutex fields")
|
||||
}
|
||||
|
||||
// Rather than deferring the unlock, we grab the standard view
|
||||
// from the field's viewMap and unlock immediately. This avoids
|
||||
// holding the rlock for a potentially long time which blocks any
|
||||
// write lock, and pending write locks block other read locks.
|
||||
f.mu.RLock()
|
||||
defer f.mu.RUnlock()
|
||||
standard := f.viewMap[viewStandard]
|
||||
f.mu.RUnlock()
|
||||
if standard == nil {
|
||||
// no standard view present means we've never needed to create it,
|
||||
// so it has no bits set, so it has no extra bits set.
|
||||
|
|
|
|||
4
view.go
4
view.go
|
|
@ -301,8 +301,8 @@ func (v *view) Fragment(shard uint64) *fragment {
|
|||
|
||||
// allFragments returns a list of all fragments in the view.
|
||||
func (v *view) allFragments() []*fragment {
|
||||
v.mu.Lock()
|
||||
defer v.mu.Unlock()
|
||||
v.mu.RLock()
|
||||
defer v.mu.RUnlock()
|
||||
|
||||
other := make([]*fragment, 0, len(v.fragments))
|
||||
for _, fragment := range v.fragments {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue