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

Alpha panics with invalid UID 0 in Dgraph #5238

Closed
danielmai opened this issue Apr 17, 2020 · 0 comments · Fixed by #5243
Closed

Alpha panics with invalid UID 0 in Dgraph #5238

danielmai opened this issue Apr 17, 2020 · 0 comments · Fixed by #5243
Assignees
Labels
area/crash Dgraph issues that cause an operation to fail, or the whole server to crash. kind/bug Something is broken. status/accepted We accept to investigate/work on it.

Comments

@danielmai
Copy link
Contributor

danielmai commented Apr 17, 2020

https://discuss.dgraph.io/t/dgraph-cluster-crashes-when-recreating-index/6353

What version of Dgraph are you using?

v20.03.0

Have you tried reproducing the issue with the latest release?

Yes.

What is the hardware spec (RAM, OS)?

N/A (macOS)

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

Alpha can panic when the dataset includes UID 0. UID 0 isn't a valid UID in Dgraph. Based on the discussion, there are two issues here:

  1. Dgraph is exporting the dataset with UID <0x0>.
  2. Dgraph accepts a write with the UID <0x0>.

Normally, when Dgraph processes a mutation with <0x0>, an error is returned saying UID has to be greater than one:

$ curl -s -H 'Content-Type: application/rdf' localhost:8080/mutate -d '{ set { <0x0> <name> "" . } }' | jq .
{
  "errors": [
    {
      "message": "UID has to be greater than one",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ],
  "data": null
}

This error also shows up for regular mutations and with live loader.

$ dgraph live -f g01.rdf.gz -s g01.schema.gz
...
Processing data file "g01.rdf.gz"
Error while mutating: UID has to be greater than one s.Code Unknown
Error while mutating: UID has to be greater than one s.Code Unknown
Error while mutating: UID has to be greater than one s.Code Unknown
Error while mutating: UID has to be greater than one s.Code Unknown

Bulk loader does not return this error and writes UIDs <0x0> to the p directory.

Steps to reproduce:

  1. Download the g01.rdf.gz and g01.schema.gz RDF and schema data set from Discuss.

  2. Start a Dgraph Zero

  3. Run bulk loader with the dataset

    dgraph bulk -f g01.rdf.gz -s g01.schema.gz
    
  4. Run Alpha with the bulk load p directory.

  5. Remove the hash index and add it back:

    $ curl localhost:8080/alter -d 'user.userName: string .'
    $ curl localhost:8080/alter -d 'user.userName: string @index(hash) .'
    
  6. Then, this panic shows up in Alpha, and restarting Alpha will show the same panic:

    2020/04/17 16:40:49 Assert failed
    github.com/dgraph-io/dgraph/x.AssertTrue
    	/ext-go/1/src/github.com/dgraph-io/dgraph/x/error.go:94
    github.com/dgraph-io/dgraph/posting.(*Txn).addIndexMutations
    	/ext-go/1/src/github.com/dgraph-io/dgraph/posting/index.go:94
    github.com/dgraph-io/dgraph/posting.rebuildTokIndex.func1.1
    	/ext-go/1/src/github.com/dgraph-io/dgraph/posting/index.go:921
    github.com/dgraph-io/dgraph/posting.(*List).iterate
    	/ext-go/1/src/github.com/dgraph-io/dgraph/posting/list.go:677
    github.com/dgraph-io/dgraph/posting.(*List).Iterate
    	/ext-go/1/src/github.com/dgraph-io/dgraph/posting/list.go:556
    github.com/dgraph-io/dgraph/posting.rebuildTokIndex.func1
    	/ext-go/1/src/github.com/dgraph-io/dgraph/posting/index.go:912
    github.com/dgraph-io/dgraph/posting.(*rebuilder).Run.func1
    	/ext-go/1/src/github.com/dgraph-io/dgraph/posting/index.go:604
    github.com/dgraph-io/badger/v2.(*Stream).produceKVs.func1
    	/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/stream.go:191
    github.com/dgraph-io/badger/v2.(*Stream).produceKVs
    	/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/stream.go:234
    github.com/dgraph-io/badger/v2.(*Stream).Orchestrate.func1
    	/go/pkg/mod/github.com/dgraph-io/badger/[email protected]/stream.go:337
    runtime.goexit
    	/usr/local/go/src/runtime/asm_amd64.s:1373
    

Expected behaviour

The Alpha should not export data with UID 0, and bulk loader should write successfully write data with UID 0.

@danielmai danielmai added kind/bug Something is broken. status/accepted We accept to investigate/work on it. area/crash Dgraph issues that cause an operation to fail, or the whole server to crash. labels Apr 17, 2020
@parasssh parasssh self-assigned this Apr 18, 2020
parasssh pushed a commit that referenced this issue Apr 20, 2020
Fixes #DGRAPH-1272
Fixes #5238
parasssh pushed a commit that referenced this issue Apr 20, 2020
Fixes #DGRAPH-1272
Fixes #5238
parasssh pushed a commit that referenced this issue Apr 20, 2020
Fixes #DGRAPH-1272
Fixes #5238

(cherry-picked from commit 09b2def)
parasssh pushed a commit that referenced this issue Apr 20, 2020
Fixes #DGRAPH-1272
Fixes #5238
parasssh pushed a commit that referenced this issue Apr 20, 2020
Fixes #DGRAPH-1272
Fixes #5238

(cherry-picked from commit 09b2def
dna2github pushed a commit to dna2fork/dgraph that referenced this issue Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/crash Dgraph issues that cause an operation to fail, or the whole server to crash. kind/bug Something is broken. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

2 participants