diff --git a/apply.go b/apply.go index aa849d6de..a8e140fec 100644 --- a/apply.go +++ b/apply.go @@ -406,7 +406,9 @@ func (sf *ShardFile) Process(cs *ChangesetRequest) error { return err } fname := sf.dest + sf.executor.TableExtension() + sf.executor.arrowmu.Lock() delete(sf.executor.arrowCache, fname) + sf.executor.arrowmu.Unlock() return os.Rename(rtemp+sf.executor.TableExtension(), fname) } diff --git a/arrow.go b/arrow.go index 1b8de9761..3ad33c0b1 100644 --- a/arrow.go +++ b/arrow.go @@ -436,7 +436,9 @@ func (e *executor) dataFrameExists(fname string) bool { } func (e *executor) getDataTable(ctx context.Context, fname string) (arrow.Table, error) { + e.arrowmu.Lock() table, ok := e.arrowCache[fname] + e.arrowmu.Unlock() if ok { vprint.VV("returning table from cache name:%v numcols:%v numrows:%v", fname, table.NumCols(), table.NumRows()) @@ -453,7 +455,9 @@ func (e *executor) getDataTable(ctx context.Context, fname string) (arrow.Table, if err != nil { return nil, err } + e.arrowmu.Lock() e.arrowCache[fname] = table + e.arrowmu.Unlock() vprint.VV("returning new table and cacheing at cache name:%v numcols:%v numrows:%v", fname, table.NumCols(), table.NumRows()) return table, nil } diff --git a/executor.go b/executor.go index ef479ad6b..308ed62a6 100644 --- a/executor.go +++ b/executor.go @@ -84,6 +84,7 @@ type executor struct { datafameUseParquet bool arrowCache map[string]arrow.Table pool memory.Allocator + arrowmu sync.Mutex } // executorOption is a functional option type for pilosa.executor