fix bitdepth race

This commit is contained in:
Ben Johnson 2020-01-06 13:52:55 -07:00
parent 1f6910b0b8
commit cda2729935
2 changed files with 20 additions and 25 deletions

View file

@ -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")
}
}
}
}

View file

@ -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.