From cda272993550a4777a25480e7a2c7359788c20bd Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Mon, 6 Jan 2020 13:52:55 -0700 Subject: [PATCH] fix bitdepth race --- executor.go | 24 ++++++++++-------------- field.go | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/executor.go b/executor.go index 125f46358..12f0897fd 100644 --- a/executor.go +++ b/executor.go @@ -3588,13 +3588,11 @@ func (e *executor) collectCallIndexNameMap(ctx context.Context, defaultIndexName m[callIndex] = struct{}{} if c.Name == "GroupBy" { - if filter, ok, err := c.CallArg("filter"); ok { - if err != nil { - return errors.Wrap(err, "getting filter call") - } - err := e.collectCallIndexNameMap(ctx, defaultIndexName, filter, m) - if err != nil { - return errors.Wrap(err, "collecting filter call index name") + for _, arg := range c.Args { + if arg, ok := arg.(*pql.Call); ok { + if err := e.collectCallIndexNameMap(ctx, defaultIndexName, arg, m); err != nil { + return errors.Wrap(err, "collecting group by call index name") + } } } } @@ -3617,13 +3615,11 @@ func (e *executor) collectCallIndexKeys(index string, idx *Index, isDefaultIndex } if callIndex := c.CallIndex(); callIndex == index || (callIndex == "" && isDefaultIndex) { - if filter, ok, err := c.CallArg("filter"); ok { - if err != nil { - return errors.Wrap(err, "getting filter call") - } - err = e.collectCallIndexKeys(index, idx, isDefaultIndex, filter, keySet) - if err != nil { - return errors.Wrap(err, "translating filter call") + for _, arg := range c.Args { + if arg, ok := arg.(*pql.Call); ok { + if err := e.collectCallIndexKeys(index, idx, isDefaultIndex, arg, keySet); err != nil { + return errors.Wrap(err, "translating group by arg call") + } } } } diff --git a/field.go b/field.go index f579bef4a..75691be52 100644 --- a/field.go +++ b/field.go @@ -1490,21 +1490,20 @@ func (f *Field) importValue(columnIDs []uint64, values []int64, options *ImportO requiredDepth = v } // Increase bit depth if required. - f.mu.RLock() - bitDepth := bsig.BitDepth - f.mu.RUnlock() - if requiredDepth > bitDepth { - if err := func() error { - f.mu.Lock() - defer f.mu.Unlock() + if err := func() error { + f.mu.Lock() + defer f.mu.Unlock() + bitDepth := bsig.BitDepth + if requiredDepth > bitDepth { bsig.BitDepth = requiredDepth f.options.BitDepth = requiredDepth return f.saveMeta() - }(); err != nil { - return errors.Wrap(err, "increasing bsi bit depth") + } else { + requiredDepth = bitDepth } - } else { - requiredDepth = bitDepth + return nil + }(); err != nil { + return errors.Wrap(err, "increasing bsi bit depth") } // Import into each fragment.