make note of a possible race condition

This commit is contained in:
Travis Turner 2017-10-30 14:28:45 -05:00
parent ed7dcdcdef
commit f2d28a1df9
No known key found for this signature in database
GPG key ID: 7F08008DFD9314C9
2 changed files with 24 additions and 19 deletions

View file

@ -725,6 +725,11 @@ func (c *Cluster) followResizeInstruction(instr *internal.ResizeInstruction) {
srcURI := decodeURI(src.URI)
// TODO: there's a possible race condition here;
// if NodeStatus has not been shared with the joining
// node (and the schema created locally), then
// the following Frame() lookup could fail.
// Retrieve frame.
f := c.Holder.Frame(src.Index, src.Frame)
if f == nil {

View file

@ -396,6 +396,25 @@ func (s *Server) mergeRemoteStatus(ns *internal.NodeStatus) error {
return nil
}
// Sync schema.
// Create indexes that don't exist.
for _, index := range ns.Schema.Indexes {
opt := IndexOptions{}
idx, err := s.Holder.CreateIndexIfNotExists(index.Name, opt)
if err != nil {
return err
}
// Create frames that don't exist.
for _, f := range index.Frames {
opt := decodeFrameOptions(f.Meta)
_, err := idx.CreateFrameIfNotExists(f.Name, *opt)
if err != nil {
return err
}
}
// TODO: Create inputDefinitions that don't exist.
}
// Sync maxSlices (standard).
oldmaxslices := s.Holder.MaxSlices()
for index, newMax := range ns.MaxSlices.Standard {
@ -428,25 +447,6 @@ func (s *Server) mergeRemoteStatus(ns *internal.NodeStatus) error {
}
}
// Sync schema.
// Create indexes that don't exist.
for _, index := range ns.Schema.Indexes {
opt := IndexOptions{}
idx, err := s.Holder.CreateIndexIfNotExists(index.Name, opt)
if err != nil {
return err
}
// Create frames that don't exist.
for _, f := range index.Frames {
opt := decodeFrameOptions(f.Meta)
_, err := idx.CreateFrameIfNotExists(f.Name, *opt)
if err != nil {
return err
}
}
// TODO: Create inputDefinitions that don't exist.
}
return nil
}