mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
Merge pull request #1442 from niaow/fix-foreignindex-race
Fix a race condition when deferring foreign-index initialization
This commit is contained in:
commit
d205ea5441
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
|
||||
|
||||
// Queue of messages to broadcast in bulk when the cluster comes up.
|
||||
// This is wrong, but. . . yeah.
|
||||
|
|
@ -764,6 +765,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