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

Query returns inconsistent results after upgrading to dgraph:v1.1.0 #4030

Closed
VarunPeddina opened this issue Sep 19, 2019 · 4 comments · Fixed by #4065
Closed

Query returns inconsistent results after upgrading to dgraph:v1.1.0 #4030

VarunPeddina opened this issue Sep 19, 2019 · 4 comments · Fixed by #4065
Assignees
Labels
area/querylang Issues related to the query language specification and implementation. kind/bug Something is broken. priority/P0 Critical issue that requires immediate attention. status/accepted We accept to investigate/work on it.

Comments

@VarunPeddina
Copy link

VarunPeddina commented Sep 19, 2019

What version of Dgraph are you using?

1.1.0

Steps to reproduce the issue (command/config used to run Dgraph).

schema

firstName: string @index(trigram) .
lastName: string @index(trigram) .

mutate

{
  set {
    _:luke <firstName> "Luke" .
    _:luke <lastName> "Skywalker" .
    _:leia <firstName> "Princess" .
    _:leia <lastName> "Leia" .
    _:han <firstName> "Han" .
    _:han <lastName> "Solo" .
    _:har <firstName> "Harrison" .
    _:har <lastName> "Ford" .
    _:ss <firstName> "Steven" .
    _:ss <lastName> "Spielberg" .
  }
}

query

{
  response(func: has(firstName)) @filter(regexp(firstName, /.*han/i) OR  regexp(lastName, /.*han/i)) {
    uid
    firstName
    lastName
  }
}

Expected behaviour and actual result.

{
  "data": {
    "response": [
      {
        "uid": "0xa1237",
        "firstName": "Han",
        "lastName": "Solo"
      }
    ]
  }
}

Keep running the same query again and again and you will see the following result intermittently

{
  "data": {
    "response": []
  }
}

Can see the desired results if we filter only on either firstName or lastName predicate, behaves like some sort of race condition.
Consistently reproducible irrespective of the transaction used NewTxn / NewReadOnlyTxn

ref: https://discuss.dgraph.io/t/dgraph-search-query-returns-inconsistent-results-after-upgrade-to-dgraph-v1-1-0/5092

@MichelDiz
Copy link
Contributor

MichelDiz commented Sep 19, 2019

Yeah, that feels like a bug.
If you run the query below it works as needed

{
  response(func: has(lastName)) @filter(
    has(lastName) AND
    regexp(firstName, /.*han/i) OR  
    regexp(lastName, /.*han/i)
  ) {
    uid
    firstName
    lastName
  }
}

@MichelDiz MichelDiz added area/querylang Issues related to the query language specification and implementation. kind/bug Something is broken. labels Sep 19, 2019
@VarunPeddina
Copy link
Author

VarunPeddina commented Sep 20, 2019

@MichelDiz Now it's returning the following error in ratel if you keep running a few times

Error Name: TypeError

Message: Failed to fetch

URL: undefined

and the following error in alpha

panic: runtime error: index out of range

goroutine 14474 [running]:
github.com/dgraph-io/dgraph/worker.(*queryState).handleUidPostings.func1(0x0, 0x5, 0x0, 0x9d9dc6)
	/tmp/go/src/github.com/dgraph-io/dgraph/worker/task.go:614 +0x15cc
github.com/dgraph-io/dgraph/worker.(*queryState).handleUidPostings.func2(0xc000d52a80, 0xc000c254a0, 0x0, 0x5)
	/tmp/go/src/github.com/dgraph-io/dgraph/worker/task.go:691 +0x3a
created by github.com/dgraph-io/dgraph/worker.(*queryState).handleUidPostings
	/tmp/go/src/github.com/dgraph-io/dgraph/worker/task.go:690 +0x3b3
[Decoder]: Using assembly version of decoder

It's not crashing if we don't use has.
This is happenning even if the predicates has just these 5 records.

@harshil-goel harshil-goel self-assigned this Sep 20, 2019
@mangalaman93 mangalaman93 added the status/accepted We accept to investigate/work on it. label Sep 21, 2019
@mangalaman93 mangalaman93 added the priority/P0 Critical issue that requires immediate attention. label Sep 23, 2019
@mangalaman93
Copy link
Contributor

Result of git bisect -

git bisect start
# bad: [4f15d4d3f63d53ef50de041e4cf7f237863a65c4] Periodically run GC in all dgraph commands. (#4032)
git bisect bad 4f15d4d3f63d53ef50de041e4cf7f237863a65c4
# bad: [7bb2f525cc231ee52cf48a45b305d2d30fb01abd] Un-export reindex functions that no longer need to be exported. (#2937)
git bisect bad 7bb2f525cc231ee52cf48a45b305d2d30fb01abd
# good: [20e2c36fa5c6cc711ab7c9f2e1023c7cf062bfe6] Add before and after dgraph MD5s to make install.
git bisect good 20e2c36fa5c6cc711ab7c9f2e1023c7cf062bfe6
# good: [20e2c36fa5c6cc711ab7c9f2e1023c7cf062bfe6] Add before and after dgraph MD5s to make install.
git bisect good 20e2c36fa5c6cc711ab7c9f2e1023c7cf062bfe6
# bad: [6d3ac389d4870e0fc650cdf04ee2d1fe91a9e8bd] Add minweight and maxweight arguments to k-shortest path algorithms. (#2915)
git bisect bad 6d3ac389d4870e0fc650cdf04ee2d1fe91a9e8bd
# bad: [a4756c206adc19b5ba640373407b30ef3a01f030] RegExp filter work without filter (#2913)
git bisect bad a4756c206adc19b5ba640373407b30ef3a01f030
# good: [c4cae75a841cbc64bafc30dd26c01b0312ed0c3c] don't create ACL predicates when the ACL feature is not turned on (#2924)
git bisect good c4cae75a841cbc64bafc30dd26c01b0312ed0c3c
# first bad commit: [a4756c206adc19b5ba640373407b30ef3a01f030] RegExp filter work without filter (#2913)

@mangalaman93
Copy link
Contributor

This is caused by a race condition -

==================
WARNING: DATA RACE
Read at 0x00c0003f38c0 by goroutine 246:
  github.com/dgraph-io/dgraph/algo.IntersectWith()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/algo/uidlist.go:138 +0x52
  github.com/dgraph-io/dgraph/worker.(*queryState).handleRegexFunction()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:1038 +0xec7
  github.com/dgraph-io/dgraph/worker.(*queryState).helpProcessTask()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:860 +0x679
  github.com/dgraph-io/dgraph/worker.processTask()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:764 +0x649
  github.com/dgraph-io/dgraph/worker.ProcessTaskOverNetwork()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:147 +0x5be
  github.com/dgraph-io/dgraph/query.ProcessGraph()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/query/query.go:1959 +0x3839

Previous write at 0x00c0003f38c0 by goroutine 271:
  github.com/dgraph-io/dgraph/algo.IntersectWith()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/algo/uidlist.go:160 +0x214
  github.com/dgraph-io/dgraph/worker.(*queryState).handleRegexFunction()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:1038 +0xec7
  github.com/dgraph-io/dgraph/worker.(*queryState).helpProcessTask()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:860 +0x679
  github.com/dgraph-io/dgraph/worker.processTask()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:764 +0x649
  github.com/dgraph-io/dgraph/worker.ProcessTaskOverNetwork()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/worker/task.go:147 +0x5be
  github.com/dgraph-io/dgraph/query.ProcessGraph()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/query/query.go:1959 +0x3839

Goroutine 246 (running) created at:
  github.com/dgraph-io/dgraph/query.ProcessGraph()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/query/query.go:2014 +0x1d6b

Goroutine 271 (finished) created at:
  github.com/dgraph-io/dgraph/query.ProcessGraph()
      /home/aman/gocode/src/github.com/dgraph-io/dgraph/query/query.go:2014 +0x1d6b
==================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/querylang Issues related to the query language specification and implementation. kind/bug Something is broken. priority/P0 Critical issue that requires immediate attention. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

4 participants