Skip to content

Commit 3271f64

Browse files
committed
Inform Zero about tablets in posting dir
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.
1 parent 839b28e commit 3271f64

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

worker/groups.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,33 @@ func StartRaftNodes(walStore *badger.DB, bindall bool) {
142142
go gr.receiveMembershipUpdates()
143143
go gr.processOracleDeltaStream()
144144

145+
go gr.informZeroAboutTablets()
145146
gr.proposeInitialSchema()
146147
}
147148

149+
func (g *groupi) informZeroAboutTablets() {
150+
// Before we start this Alpha, let's pick up all the predicates we have in our postings
151+
// directory, and ask Zero if we are allowed to serve it. Do this irrespective of whether
152+
// this node is the leader or the follower, because this early on, we might not have
153+
// figured that out.
154+
ticker := time.NewTicker(time.Second)
155+
defer ticker.Stop()
156+
157+
for range ticker.C {
158+
failed := false
159+
preds := schema.State().Predicates()
160+
for _, pred := range preds {
161+
if tablet := g.Tablet(pred); tablet == nil {
162+
failed = true
163+
}
164+
}
165+
if !failed {
166+
glog.V(1).Infof("Done informing Zero about the %d tablets I have", len(preds))
167+
return
168+
}
169+
}
170+
}
171+
148172
func (g *groupi) proposeInitialSchema() {
149173
// propose the schema for _predicate_
150174
if Config.ExpandEdge {

0 commit comments

Comments
 (0)