Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(schema): log error instead of panic if schema not found for predicate #7502

Merged
merged 1 commit into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,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