mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
Merge pull request #1661 from molecula/other-client-rowCache-race
fix other batch client rowCache race
This commit is contained in:
commit
e42c96e996
1 changed files with 4 additions and 0 deletions
|
|
@ -824,6 +824,8 @@ func (b *Batch) doTranslation() error {
|
|||
rowCache = make(map[string]agedTranslation)
|
||||
b.rowTranslations[fieldName] = rowCache
|
||||
}
|
||||
// create a lock since we're updating this concurrently below
|
||||
rowCacheLock := &sync.Mutex{}
|
||||
|
||||
i, tt := i, tt
|
||||
eg.Go(func() error {
|
||||
|
|
@ -845,12 +847,14 @@ func (b *Batch) doTranslation() error {
|
|||
b.log.Debugf("translating %d field keys for %s took %v", len(trans), fieldName, time.Since(start))
|
||||
|
||||
// Apply keys to translation cache.
|
||||
rowCacheLock.Lock()
|
||||
for key, id := range trans {
|
||||
rowCache[key] = agedTranslation{
|
||||
id: id,
|
||||
lastUsed: b.cycle,
|
||||
}
|
||||
}
|
||||
rowCacheLock.Unlock()
|
||||
|
||||
switch ftype := field.Opts().Type(); ftype {
|
||||
case FieldTypeSet, FieldTypeMutex, FieldTypeTime:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue