mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 16:45:55 +00:00
fix a race condition when deferring foreign-index initialization
This commit is contained in:
parent
a1d4418236
commit
ca918c187d
1 changed files with 4 additions and 1 deletions
|
|
@ -121,7 +121,8 @@ type Holder struct {
|
|||
|
||||
// Queue of fields (having a foreign index) which have
|
||||
// opened before their foreign index has opened.
|
||||
foreignIndexFields []*Field
|
||||
foreignIndexFields []*Field
|
||||
foreignIndexFieldsMu sync.Mutex
|
||||
|
||||
// opening is set to true while Holder is opening.
|
||||
// It's used to determine if foreign index application
|
||||
|
|
@ -738,6 +739,8 @@ func (h *Holder) Activate() {
|
|||
func (h *Holder) checkForeignIndex(f *Field) error {
|
||||
if h.opening {
|
||||
if fi := h.Index(f.options.ForeignIndex); fi == nil {
|
||||
h.foreignIndexFieldsMu.Lock()
|
||||
defer h.foreignIndexFieldsMu.Unlock()
|
||||
h.foreignIndexFields = append(h.foreignIndexFields, f)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue