From 1409ab56645b490123aa51d9e1d26bfdd04030be Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 31 Dec 2019 09:21:36 -0700 Subject: [PATCH] fix data race --- field.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/field.go b/field.go index cd6b9c7ae..f579bef4a 100644 --- a/field.go +++ b/field.go @@ -1490,7 +1490,10 @@ func (f *Field) importValue(columnIDs []uint64, values []int64, options *ImportO requiredDepth = v } // Increase bit depth if required. - if requiredDepth > bsig.BitDepth { + f.mu.RLock() + bitDepth := bsig.BitDepth + f.mu.RUnlock() + if requiredDepth > bitDepth { if err := func() error { f.mu.Lock() defer f.mu.Unlock() @@ -1501,7 +1504,7 @@ func (f *Field) importValue(columnIDs []uint64, values []int64, options *ImportO return errors.Wrap(err, "increasing bsi bit depth") } } else { - requiredDepth = bsig.BitDepth + requiredDepth = bitDepth } // Import into each fragment.