mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-07 00:55:55 +00:00
Move applyCreatedAt from mergeClusterStatus directly to ClusterStatus message, to avoid deadlocks
This commit is contained in:
parent
0c98c887ac
commit
d8a417f657
4 changed files with 15 additions and 13 deletions
17
api.go
17
api.go
|
|
@ -181,15 +181,17 @@ func (api *API) CreateIndex(ctx context.Context, indexName string, options Index
|
|||
if err != nil {
|
||||
return nil, errors.Wrap(err, "creating index")
|
||||
}
|
||||
|
||||
createdAt := timestamp()
|
||||
index.mu.Lock()
|
||||
index.createdAt = timestamp()
|
||||
index.createdAt = createdAt
|
||||
index.mu.Unlock()
|
||||
|
||||
// Send the create index message to all nodes.
|
||||
err = api.server.SendSync(
|
||||
&CreateIndexMessage{
|
||||
Index: indexName,
|
||||
CreatedAt: index.CreatedAt(),
|
||||
CreatedAt: createdAt,
|
||||
Meta: &options,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -274,15 +276,16 @@ func (api *API) CreateField(ctx context.Context, indexName string, fieldName str
|
|||
if err != nil {
|
||||
return nil, errors.Wrap(err, "creating field")
|
||||
}
|
||||
createdAt := timestamp()
|
||||
field.mu.Lock()
|
||||
field.createdAt = timestamp()
|
||||
field.createdAt = createdAt
|
||||
field.mu.Unlock()
|
||||
|
||||
// Send the create field message to all nodes.
|
||||
err = api.server.SendSync(&CreateFieldMessage{
|
||||
Index: indexName,
|
||||
Field: fieldName,
|
||||
CreatedAt: field.CreatedAt(),
|
||||
CreatedAt: createdAt,
|
||||
Meta: &fo,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -836,11 +839,7 @@ func (api *API) ApplySchema(ctx context.Context, s *Schema, remote bool) error {
|
|||
}
|
||||
}
|
||||
|
||||
if err := api.holder.applySchema(s); err != nil {
|
||||
return errors.Wrap(err, "applying schema")
|
||||
}
|
||||
|
||||
return nil
|
||||
return errors.Wrap(api.holder.applySchema(s), "applying schema")
|
||||
}
|
||||
|
||||
// Views returns the views in the given field.
|
||||
|
|
|
|||
|
|
@ -2214,9 +2214,6 @@ func (c *cluster) mergeClusterStatus(cs *ClusterStatus) error {
|
|||
}
|
||||
}
|
||||
|
||||
if cs.Schema != nil {
|
||||
c.holder.applyCreatedAt(cs.Schema.Indexes)
|
||||
}
|
||||
c.unprotectedSetState(cs.State)
|
||||
|
||||
c.markAsJoined()
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ func stringSlicesAreEqual(a, b []string) bool {
|
|||
}
|
||||
|
||||
func timestamp() int64 {
|
||||
return time.Now().UTC().UnixNano()
|
||||
return time.Now().UnixNano()
|
||||
}
|
||||
|
||||
// AddressWithDefaults converts addr into a valid address,
|
||||
|
|
|
|||
|
|
@ -770,6 +770,12 @@ func (s *Server) receiveMessage(m Message) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !s.isCoordinator {
|
||||
if obj.Schema != nil {
|
||||
s.holder.applyCreatedAt(obj.Schema.Indexes)
|
||||
}
|
||||
}
|
||||
|
||||
case *ResizeInstruction:
|
||||
err := s.cluster.followResizeInstruction(obj)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue