Skip to content

Commit

Permalink
fix(schema): log error instead of panic if schema not found for predi…
Browse files Browse the repository at this point in the history
…cate (#7502) (#7509)

This PR fixes alpha panic when drop operation and the query is run concurrently.
This may happen when some query that needs indexing over this predicate is executing while the predicate is dropped from the state (using drop operation).

(cherry picked from commit 96073fc)
  • Loading branch information
NamanJain8 authored Mar 8, 2021
1 parent 94f3a04 commit 48f22eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ func (s *state) Tokenizer(ctx context.Context, pred string) []tok.Tokenizer {
su = schema
}
}
x.AssertTruef(su != nil, "schema state not found for %s", pred)
if su == nil {
// This may happen when some query that needs indexing over this predicate is executing
// while the predicate is dropped from the state (using drop operation).
glog.Errorf("Schema state not found for %s.", pred)
return nil
}
tokenizers := make([]tok.Tokenizer, 0, len(su.Tokenizer))
for _, it := range su.Tokenizer {
t, found := tok.GetTokenizer(it)
Expand Down
3 changes: 3 additions & 0 deletions worker/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ func pickTokenizer(ctx context.Context, attr string, f string) (tok.Tokenizer, e
}

tokenizers := schema.State().Tokenizer(ctx, attr)
if tokenizers == nil {
return nil, errors.Errorf("Schema state not found for %s.", attr)
}
for _, t := range tokenizers {
// If function is eq and we found a tokenizer that's !Lossy(), lets return it
switch f {
Expand Down

0 comments on commit 48f22eb

Please sign in to comment.