Merge pull request #1662 from molecula/rowcache-race-again

need to create rowCache lock at the top... otherwise it does nothing
This commit is contained in:
Mahesh Arumugam 2021-07-20 11:06:38 -07:00 committed by GitHub
commit abb9b930bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -806,6 +806,14 @@ func (b *Batch) doTranslation() error {
return nil
})
// creating a lock up here for the rowCache(s) which we get
// below. Usually this isn't needed, but sometimes I think the
// same rowCache gets used repeatedly because the same field is in
// there multiple times, and that can lead to race
// conditions. Need to understand this better, but gonna see if
// this avoids the races.
rowCacheLock := &sync.Mutex{}
// Translate the row keys.
for i, tt := range b.toTranslate {
// Skip this if there are no keys to translate.
@ -824,8 +832,6 @@ 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 {
@ -921,8 +927,6 @@ 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{}
fieldName, tt := fieldName, tt
eg.Go(func() error {