mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-06 19:07:50 +00:00
prevent concurrent map writes in openField
Prior to this, we locked the index-wide i.mu around writes to i.fields. But now the entire open process is holding that lock, so we couldn't lock it here (that'd deadlock) and didn't think we needed to (because it was held). But in fact that means that multiple fields being opened at once can concurrently write to the map. Conveniently, we *already* pass a shared mutex into openField() to prevent exactly this sort of problem; we just need to actually use it when doing the write.
This commit is contained in:
parent
a9b56b055e
commit
70760b187f
1 changed files with 2 additions and 0 deletions
2
index.go
2
index.go
|
|
@ -341,7 +341,9 @@ func (i *Index) openField(mu *sync.Mutex, cfm *CreateFieldMessage, file string)
|
|||
}
|
||||
|
||||
i.holder.Logger.Debugf("add field to index.fields: %s", file)
|
||||
mu.Lock()
|
||||
i.fields[fld.Name()] = fld
|
||||
mu.Unlock()
|
||||
|
||||
return fld, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue