Skip to content

Commit

Permalink
Inform Zero about tablets in posting dir
Browse files Browse the repository at this point in the history
When Alpha starts, it should inform Zero about the predicates it is
serving, so that Zero can then allow it to serve those predicates. Right
now that doesn't happen, which means some other group could start
serving the predicate without having the data for it.

This PR fixes that by using the schema to determine which predicates
Alpha has in the postings dir and informs Zero about these.
  • Loading branch information
manishrjain committed Feb 22, 2019
1 parent 839b28e commit 3271f64
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions worker/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,33 @@ func StartRaftNodes(walStore *badger.DB, bindall bool) {
go gr.receiveMembershipUpdates()
go gr.processOracleDeltaStream()

go gr.informZeroAboutTablets()
gr.proposeInitialSchema()
}

func (g *groupi) informZeroAboutTablets() {
// Before we start this Alpha, let's pick up all the predicates we have in our postings
// directory, and ask Zero if we are allowed to serve it. Do this irrespective of whether
// this node is the leader or the follower, because this early on, we might not have
// figured that out.
ticker := time.NewTicker(time.Second)
defer ticker.Stop()

for range ticker.C {
failed := false
preds := schema.State().Predicates()
for _, pred := range preds {
if tablet := g.Tablet(pred); tablet == nil {
failed = true
}
}
if !failed {
glog.V(1).Infof("Done informing Zero about the %d tablets I have", len(preds))
return
}
}
}

func (g *groupi) proposeInitialSchema() {
// propose the schema for _predicate_
if Config.ExpandEdge {
Expand Down

0 comments on commit 3271f64

Please sign in to comment.