dgraph-io / dgraph

The high-performance database for modern applications
https://dgraph.io
Other
20.35k stars 1.49k forks source link

Delete edge which object’s valueType is uid in binaries version failed. #1925

Closed yunzhongshu closed 6 years ago

yunzhongshu commented 6 years ago

If you suspect this could be a bug, follow the template.

v0.9.4

When I run dgraph server with the binaries version v0.9.4, i run the java client such as

Mutation.Builder b = Mutation.newBuilder(mu);
b.addDel(
                  NQuad.newBuilder()
                            .setSubject(uid)
                            .setPredicate(predicate)
                            .setObjectId(valueUid)            // valueUid is the Object's uid
                            .build()
).build();

the server throw an exeption such as

Exception in thread "main" io.grpc.StatusRuntimeException: UNKNOWN: Please use * with delete operation for non-list type
    at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:210)
    at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:191)
    at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:124)
    at io.dgraph.DgraphGrpc$DgraphBlockingStub.mutate(DgraphGrpc.java:298)
    at io.dgraph.DgraphClient$Transaction.mutate(DgraphClient.java:211)

but when i run dgraph with the source code , i success delete the edge use the same java code

can anyone tell me why. (is the binaries version is not use the newest source code?)

peterstace commented 6 years ago

I don't think anything should have changed with regard to deletes between v0.9.4 and master, so this is odd.

Could you add the exact steps to reproduce? e.g. what your schema is, and what RDFs have already been loaded.

yunzhongshu commented 6 years ago

I found the code at v0.9.4 in the file mutation.go line 298 is

    if len(edge.Value) > 0 && !bytes.Equal(edge.Value, []byte(x.Star)) &&
        edge.Op == intern.DirectedEdge_DEL {
        if !schema.State().IsList(edge.Attr) {
            return x.Errorf("Please use * with delete operation for non-list type")
        }
    }

But the same code at master is

    if edge.ValueId == 0 && !bytes.Equal(edge.Value, []byte(x.Star)) &&
        edge.Op == intern.DirectedEdge_DEL {
        if !schema.State().IsList(edge.Attr) {
            return x.Errorf("Please use * with delete operation for non-list type")
        }
    }
peterstace commented 6 years ago

You're right, that code has definitely changed and looks to be the cause of the behavioural difference you're seeing.

It looks to me like the before/after should be equivalent though.

Would you be able to copy/paste the mutation that you sent that caused the exception, along with the schema that you have? That will really help us to track down what is going wrong here.

manishrjain commented 6 years ago

Also, CC: @deepakjois because he's handling the Java client.

yunzhongshu commented 6 years ago

I find the same err will happen at the Master. And the wrong reason is the Del Mutation.Edges add the edge attrbuted '_predicate_' with no valueId in it. The code is in query/mutation.go, line 74

        for _, pred := range preds {
            edgeCopy := *edge
            edgeCopy.Attr = pred
            edges = append(edges, &edgeCopy)

            e := &intern.DirectedEdge{
                Op:     edge.Op,
                Entity: edge.GetEntity(),
                Attr:   "_predicate_",
                Value:  []byte(pred),
            }
            edges = append(edges, e)
        }

so when check "ValidateAndConvert" func in worker/mutation.go , it will be throw the error "Please use * with delete operation for non-list type"

janardhan1993 commented 6 years ago

Can you please query the schema and share. The error shouldn't happen because predicate is of list type.

yunzhongshu commented 6 years ago
{
  "data": {
    "schema": [
      {
        "predicate": "_predicate_",
        "type": "default"
      },
      {
        "predicate": "director",
        "type": "uid"
      },
      {
        "predicate": "name",
        "type": "string",
        "index": true,
        "tokenizer": [
          "term"
        ]
      },
      {
        "predicate": "release_date",
        "type": "datetime",
        "index": true,
        "tokenizer": [
          "year"
        ]
      },
      {
        "predicate": "revenue",
        "type": "float"
      },
      {
        "predicate": "running_time",
        "type": "int"
      },
      {
        "predicate": "starring",
        "type": "uid"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 169,
      "processing_ns": 533,
      "encoding_ns": 525244
    },
    "txn": {
      "start_ts": 70041,
      "lin_read": {}
    }
  }
}
yunzhongshu commented 6 years ago

set _predicate_ 's valueType to list?

janardhan1993 commented 6 years ago

predicate schema is wrong. Can you please share the dgraph server's log when you started it. It should have been automatically set to list type.

yunzhongshu commented 6 years ago
2017/12/18 16:03:54 groups.go:94: Current Raft Id: 1
2017/12/18 16:03:54 gRPC server started.  Listening on port 9080
2017/12/18 16:03:54 worker.go:99: Worker listening at address: [::]:7080
2017/12/18 16:03:54 HTTP server started.  Listening on port 8080
2017/12/18 16:03:54 pool.go:118: == CONNECT ==> Setting localhost:5080
2017/12/18 16:03:54 groups.go:117: Connected to group zero. Connection state: member:<id:1 addr:"localhost:7080" > state:<counter:175 groups:<key:1 value:<members:<key:1 value:<id:1 group_id:1 addr:"localhost:7080" leader:true last_update:1513583517 > > tablets:<key:"_dummy_" value:<group_id:1 predicate:"_dummy_" space:19 > > tablets:<key:"_predicate_" value:<group_id:1 predicate:"_predicate_" space:800 > > tablets:<key:"director" value:<group_id:1 predicate:"director" space:105 > > tablets:<key:"name" value:<group_id:1 predicate:"name" space:2147 > > tablets:<key:"release_date" value:<group_id:1 predicate:"release_date" space:512 > > tablets:<key:"revenue" value:<group_id:1 predicate:"revenue" space:320 > > tablets:<key:"running_time" value:<group_id:1 predicate:"running_time" space:340 > > tablets:<key:"starring" value:<group_id:1 predicate:"starring" space:303 > > > > zeros:<key:1 value:<id:1 addr:"localhost:5080" leader:true > > maxLeaseId:80000 maxTxnTs:80000 maxRaftId:1 > 
2017/12/18 16:03:54 draft.go:140: Node ID: 1 with GroupID: 1
2017/12/18 16:03:54 node.go:233: Found Snapshot: {Data:[9 1 0 0 0 0 0 0 0 16 1 26 14 108 111 99 97 108 104 111 115 116 58 55 48 56 48] Metadata:{ConfState:{Nodes:[1] XXX_unrecognized:[]} Index:61 Term:19 XXX_unrecognized:[]} XXX_unrecognized:[]}
2017/12/18 16:03:54 node.go:248: Found hardstate: {Term:30 Vote:1 Commit:109 XXX_unrecognized:[]}
2017/12/18 16:03:54 node.go:260: Group 1 found 48 entries
2017/12/18 16:03:54 draft.go:657: Restarting node for group: 1
2017/12/18 16:03:54 raft.go:567: INFO: 1 became follower at term 30
2017/12/18 16:03:54 raft.go:315: INFO: newRaft 1 [peers: [1], term: 30, commit: 109, applied: 61, lastindex: 109, lastterm: 30]
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:173: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:173: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:173: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:173: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"name" value_type:STRING directive:INDEX tokenizer:"term" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"release_date" value_type:DATETIME directive:INDEX tokenizer:"year" 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"revenue" value_type:FLOAT 
2017/12/18 16:03:54 mutation.go:152: Done schema update predicate:"running_time" value_type:INT 
2017/12/18 16:03:57 raft.go:749: INFO: 1 is starting a new election at term 30
2017/12/18 16:03:57 raft.go:580: INFO: 1 became candidate at term 31
2017/12/18 16:03:57 raft.go:664: INFO: 1 received MsgVoteResp from 1 at term 31
2017/12/18 16:03:57 raft.go:621: INFO: 1 became leader at term 31
2017/12/18 16:03:57 node.go:301: INFO: raft.node: 1 elected leader 1 at term 31
yunzhongshu commented 6 years ago

I set the schema and add data with the step3 in https://docs.dgraph.io/get-started/

janardhan1993 commented 6 years ago

Can you please share more logs after restart and if possible logs before restart also.

yunzhongshu commented 6 years ago

before restart

GOROOT=/usr/local/go
GOPATH=/Users/xxxxx/Work/workspace/go
/usr/local/go/bin/go build -i -o /private/var/folders/62/576h7ghn6vn22rkhv4nzzl0m0000gn/T/servergo /Users/xxxx/Work/workspace/go/src/github.com/dgraph-io/dgraph/dgraph/main.go
# command-line-arguments
ld: warning: PIE disabled. Absolute addressing (perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in type..eqfunc.[101]interface {} from /var/folders/62/576h7ghn6vn22rkhv4nzzl0m0000gn/T/go-link-918221810/go.o. To fix this warning, don't compile with -mdynamic-no-pic or link with -Wl,-no_pie
/private/var/folders/62/576h7ghn6vn22rkhv4nzzl0m0000gn/T/servergo server --memory_mb 2048 --zero localhost:5080
janardhan1993 commented 6 years ago

These are not the full logs. Can you please share the steps to reproduce this on a fresh dgraph instance.

yunzhongshu commented 6 years ago

I have done these commands with the binary version:

  1. dropAll 2.add demo datas

    curl localhost:8080/mutate -H "X-Dgraph-CommitNow: true" -XPOST -d $'
    {
    set {
    _:luke <name> "Luke Skywalker" .
    _:leia <name> "Princess Leia" .
    _:han <name> "Han Solo" .
    _:lucas <name> "George Lucas" .
    _:irvin <name> "Irvin Kernshner" .
    _:richard <name> "Richard Marquand" .
    
    _:sw1 <name> "Star Wars: Episode IV - A New Hope" .
    _:sw1 <release_date> "1977-05-25" .
    _:sw1 <revenue> "775000000" .
    _:sw1 <running_time> "121" .
    _:sw1 <starring> _:luke .
    _:sw1 <starring> _:leia .
    _:sw1 <starring> _:han .
    _:sw1 <director> _:lucas .
    
    _:sw2 <name> "Star Wars: Episode V - The Empire Strikes Back" .
    _:sw2 <release_date> "1980-05-21" .
    _:sw2 <revenue> "534000000" .
    _:sw2 <running_time> "124" .
    _:sw2 <starring> _:luke .
    _:sw2 <starring> _:leia .
    _:sw2 <starring> _:han .
    _:sw2 <director> _:irvin .
    
    _:sw3 <name> "Star Wars: Episode VI - Return of the Jedi" .
    _:sw3 <release_date> "1983-05-25" .
    _:sw3 <revenue> "572000000" .
    _:sw3 <running_time> "131" .
    _:sw3 <starring> _:luke .
    _:sw3 <starring> _:leia .
    _:sw3 <starring> _:han .
    _:sw3 <director> _:richard .
    
    _:st1 <name> "Star Trek: The Motion Picture" .
    _:st1 <release_date> "1979-12-07" .
    _:st1 <revenue> "139000000" .
    _:st1 <running_time> "132" .
    }
    }
    ' | python -m json.tool | less

    3.set schema

    curl localhost:8080/alter -XPOST -d $'
    name: string @index(term) .
    release_date: datetime @index(year) .
    revenue: float .
    running_time: int .
    ' | python -m json.tool | less

    and then see the schema

    {
    "data": {
    "schema": [
      {
        "predicate": "director",
        "type": "uid"
      },
      {
        "predicate": "name",
        "type": "string",
        "index": true,
        "tokenizer": [
          "term"
        ]
      },
      {
        "predicate": "release_date",
        "type": "datetime",
        "index": true,
        "tokenizer": [
          "year"
        ]
      },
      {
        "predicate": "revenue",
        "type": "float"
      },
      {
        "predicate": "running_time",
        "type": "int"
      },
      {
        "predicate": "starring",
        "type": "uid"
      }
    ]
    },
    "extensions": {
    "server_latency": {
      "parsing_ns": 116,
      "processing_ns": 421,
      "encoding_ns": 776759
    },
    "txn": {
      "start_ts": 80013,
      "lin_read": {}
    }
    }
    }

    there have no '_predicate_' ? Is it right?

yunzhongshu commented 6 years ago

restart logs:

2017/12/18 16:39:59 groups.go:94: Current Raft Id: 1
2017/12/18 16:39:59 gRPC server started.  Listening on port 9080
2017/12/18 16:39:59 HTTP server started.  Listening on port 8080
2017/12/18 16:39:59 worker.go:99: Worker listening at address: [::]:7080
2017/12/18 16:39:59 pool.go:118: == CONNECT ==> Setting localhost:5080
2017/12/18 16:39:59 groups.go:117: Connected to group zero. Connection state: member:<id:1 addr:"localhost:7080" > state:<counter:3608 groups:<key:1 value:<members:<key:1 value:<id:1 group_id:1 addr:"localhost:7080" leader:true last_update:1513586312 > > tablets:<key:"$ref" value:<group_id:1 predicate:"$ref" space:280 > > tablets:<key:"ValueId" value:<group_id:1 predicate:"ValueId" > > tablets:<key:"_dummy_" value:<group_id:1 predicate:"_dummy_" space:19 > > tablets:<key:"_predicate_" value:<group_id:1 predicate:"_predicate_" space:800 > > tablets:<key:"_uid_" value:<group_id:1 predicate:"_uid_" > > tablets:<key:"address" value:<group_id:1 predicate:"address" space:336 > > tablets:<key:"age" value:<group_id:1 predicate:"age" > > tablets:<key:"bal" value:<group_id:1 predicate:"bal" > > tablets:<key:"balance" value:<group_id:1 predicate:"balance" > > tablets:<key:"both" value:<group_id:1 predicate:"both" > > tablets:<key:"call" value:<group_id:1 predicate:"call" space:547 > > tablets:<key:"calls" value:<group_id:1 predicate:"calls" space:162 > > tablets:<key:"contact" value:<group_id:1 predicate:"contact" space:498 > > tablets:<key:"contacts" value:<group_id:1 predicate:"contacts" > > tablets:<key:"director" value:<group_id:1 predicate:"director" space:105 > > tablets:<key:"first" value:<group_id:1 predicate:"first" > > tablets:<key:"friends" value:<group_id:1 predicate:"friends" > > tablets:<key:"id" value:<group_id:1 predicate:"id" > > tablets:<key:"label" value:<group_id:1 predicate:"label" > > tablets:<key:"last" value:<group_id:1 predicate:"last" > > tablets:<key:"loc" value:<group_id:1 predicate:"loc" > > tablets:<key:"location" value:<group_id:1 predicate:"location" > > tablets:<key:"married" value:<group_id:1 predicate:"married" > > tablets:<key:"name" value:<group_id:1 predicate:"name" space:2147 > > tablets:<key:"objectId" value:<group_id:1 predicate:"objectId" > > tablets:<key:"phone" value:<group_id:1 predicate:"phone" space:193 > > tablets:<key:"release_date" value:<group_id:1 predicate:"release_date" space:512 > > tablets:<key:"revenue" value:<group_id:1 predicate:"revenue" space:316 > > tablets:<key:"running_time" value:<group_id:1 predicate:"running_time" space:312 > > tablets:<key:"schools" value:<group_id:1 predicate:"schools" > > tablets:<key:"starring" value:<group_id:1 predicate:"starring" space:285 > > tablets:<key:"subjectId" value:<group_id:1 predicate:"subjectId" > > tablets:<key:"when" value:<group_id:1 predicate:"when" > > tablets:<key:"xid" value:<group_id:1 predicate:"xid" > > > > zeros:<key:1 value:<id:1 addr:"localhost:5080" leader:true > > maxLeaseId:50000 maxTxnTs:90000 maxRaftId:18 >
2017/12/18 16:39:59 draft.go:140: Node ID: 1 with GroupID: 1
2017/12/18 16:39:59 node.go:233: Found Snapshot: {Data:[9 1 0 0 0 0 0 0 0 16 1 26 14 108 111 99 97 108 104 111 115 116 58 55 48 56 48] Metadata:{ConfState:{Nodes:[1] XXX_unrecognized:[]} Index:10425 Term:11 XXX_unrecognized:[]} XXX_unrecognized:[]}
2017/12/18 16:39:59 node.go:248: Found hardstate: {Term:11 Vote:1 Commit:10425 XXX_unrecognized:[]}
2017/12/18 16:39:59 node.go:260: Group 1 found 0 entries
2017/12/18 16:39:59 draft.go:654: Restarting node for group: 1
2017/12/18 16:39:59 raft.go:567: INFO: 1 became follower at term 11
2017/12/18 16:39:59 raft.go:316: INFO: newRaft 1 [peers: [1], term: 11, commit: 10425, applied: 10425, lastindex: 10425, lastterm: 11]
2017/12/18 16:40:02 raft.go:749: INFO: 1 is starting a new election at term 11
2017/12/18 16:40:02 raft.go:580: INFO: 1 became candidate at term 12
2017/12/18 16:40:02 raft.go:664: INFO: 1 received MsgVoteResp from 1 at term 12
2017/12/18 16:40:02 raft.go:621: INFO: 1 became leader at term 12
2017/12/18 16:40:02 node.go:301: INFO: raft.node: 1 elected leader 1 at term 12
janardhan1993 commented 6 years ago

Thanks for the logs, will look into it.

yunzhongshu commented 6 years ago

Then i can delete the edge for the first time, then the schema change to

{
  "data": {
    "schema": [
      {
        "predicate": "_predicate_",
        "type": "default"
      },
      {
        "predicate": "director",
        "type": "uid"
      },
      {
        "predicate": "name",
        "type": "string",
        "index": true,
        "tokenizer": [
          "term"
        ]
      },
      {
        "predicate": "release_date",
        "type": "datetime",
        "index": true,
        "tokenizer": [
          "year"
        ]
      },
      {
        "predicate": "revenue",
        "type": "float"
      },
      {
        "predicate": "running_time",
        "type": "int"
      },
      {
        "predicate": "starring",
        "type": "uid"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 203,
      "processing_ns": 655,
      "encoding_ns": 562142
    },
    "txn": {
      "start_ts": 80023,
      "lin_read": {}
    }
  }
}

it has the '_predicate_' predicate in it and then I can't delete other edges .

peterstace commented 6 years ago

When I try to reproduce the problem following your steps, I can't reproduce it.

  1. Run drop all:
$ curl localhost:8080/alter -XPOST -d '{"dropall": true}' | jq         
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    61  100    44  100    17     44     17  0:00:01 --:--:--  0:00:01 61000
{
  "data": {
    "code": "Success",
    "message": "Done"
  }
}

Set data:

$ curl localhost:8080/mutate -H "X-Dgraph-CommitNow: true" -XPOST -d $'
{
  set {
   _:luke <name> "Luke Skywalker" .
   _:leia <name> "Princess Leia" .
   _:han <name> "Han Solo" .
   _:lucas <name> "George Lucas" .
   _:irvin <name> "Irvin Kernshner" .
   _:richard <name> "Richard Marquand" .

   _:sw1 <name> "Star Wars: Episode IV - A New Hope" .
   _:sw1 <release_date> "1977-05-25" .
   _:sw1 <revenue> "775000000" .
   _:sw1 <running_time> "121" .
   _:sw1 <starring> _:luke .
   _:sw1 <starring> _:leia .
   _:sw1 <starring> _:han .
   _:sw1 <director> _:lucas .

   _:sw2 <name> "Star Wars: Episode V - The Empire Strikes Back" .
   _:sw2 <release_date> "1980-05-21" .
   _:sw2 <revenue> "534000000" .
   _:sw2 <running_time> "124" .
   _:sw2 <starring> _:luke .
   _:sw2 <starring> _:leia .
   _:sw2 <starring> _:han .
   _:sw2 <director> _:irvin .

   _:sw3 <name> "Star Wars: Episode VI - Return of the Jedi" .
   _:sw3 <release_date> "1983-05-25" .
   _:sw3 <revenue> "572000000" .
   _:sw3 <running_time> "131" .
   _:sw3 <starring> _:luke .
   _:sw3 <starring> _:leia .
   _:sw3 <starring> _:han .
   _:sw3 <director> _:richard .

   _:st1 <name> "Star Trek: The Motion Picture" .
   _:st1 <release_date> "1979-12-07" .
   _:st1 <revenue> "139000000" .
   _:st1 <running_time> "132" .
  }
}
' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1503  100   267  100  1236    267   1236  0:00:01 --:--:--  0:00:01 62625
{
  "data": {
    "code": "Success",
    "message": "Done",
    "uids": {
      "han": "0x13",
      "irvin": "0xe",
      "leia": "0x12",
      "lucas": "0xd",
      "luke": "0x11",
      "richard": "0xf",
      "st1": "0xc",
      "sw1": "0x10",
      "sw2": "0x14",
      "sw3": "0xb"
    }
  },
  "extensions": {
    "txn": {
      "start_ts": 13,
      "commit_ts": 14,
      "lin_read": {
        "ids": {
          "1": 7
        }
      }
    }
  }
}
  1. Set schema:
$ curl localhost:8080/alter -XPOST -d $'                               
  name: string @index(term) .
  release_date: datetime @index(year) .
  revenue: float .
  running_time: int .
' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   156  100    44  100   112     44    112  0:00:01 --:--:--  0:00:01  1380
{
  "data": {
    "code": "Success",
    "message": "Done"
  }
}
  1. Show schema:
$ curl localhost:8080/query -XPOST -d 'schema{}' | jq                  
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   522  100   514  100     8    514      8  0:00:01 --:--:--  0:00:01  509k
{
  "data": {
    "schema": [
      {
        "predicate": "_predicate_",
        "type": "string",
        "list": true
      },
      {
        "predicate": "director",
        "type": "uid"
      },
      {
        "predicate": "name",
        "type": "string",
        "index": true,
        "tokenizer": [
          "term"
        ]
      },
      {
        "predicate": "release_date",
        "type": "datetime",
        "index": true,
        "tokenizer": [
          "year"
        ]
      },
      {
        "predicate": "revenue",
        "type": "float"
      },
      {
        "predicate": "running_time",
        "type": "int"
      },
      {
        "predicate": "starring",
        "type": "uid"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 427,
      "processing_ns": 701,
      "encoding_ns": 443480
    },
    "txn": {
      "start_ts": 16,
      "lin_read": {}
    }
  }
}

_predicate_ is definitely present, and is set with list type correctly.

Were there any other steps that you were taking?

yunzhongshu commented 6 years ago

I do the operate follow yours, And still the '_predicate_' valueType is 'default'.

peterstace commented 6 years ago

And that was with the 0.9.4 binary? Or with master?

peterstace commented 6 years ago

Can you reproduce the problem if you start with fresh data directories? (p and w). Possibly it has something to do with state between restarts.

yunzhongshu commented 6 years ago

0.9.4 binary and the master have the same problem

peterstace commented 6 years ago

Is it possible for you to send me the p and w directories? That would help to debug what is going wrong.

yunzhongshu commented 6 years ago

And when I restart the dgraph server , the schema '_predicate_' disapeared

yunzhongshu commented 6 years ago

I'm sorry, how can i get the p and w directories

peterstace commented 6 years ago

And when I restart the dgraph server , the schema 'predicate' disapeared

When should I restart the dgraph server in order to reproduce? Is that as the last step?

The w and p directories should be in the directory that you ran the dgraph command from.

yunzhongshu commented 6 years ago

When should I restart the dgraph server in order to reproduce? Is that as the last step?

yes

yunzhongshu commented 6 years ago

p and w.zip

peterstace commented 6 years ago

Thanks for the zip file, I'll continue investigating.

peterstace commented 6 years ago

I started up dgraph using the p and w dirs you gave. But it doesn't show the problem.

I used the following commands (with the zip file exanded into the directory I ran the commands from):

$ dgraph zero
$ dgraph server --memory_mb=1024 --zero localhost:7080 -o -3000

During start up, I see the following in the dgraph server log:

2017/12/19 14:26:02 mutation.go:152: Done schema update predicate:"_predicate_" value_type:STRING list:true

So for me, the _predicate_ schema is being added on startup. Querying the schema shows the same thing:

$ curl localhost:5080/query -XPOST -d 'schema{}' | jq 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   522  100   514  100     8    514      8  0:00:01 --:--:--  0:00:01 37285
{
  "data": {
    "schema": [
      {
        "predicate": "_predicate_",
        "type": "string",
        "list": true
      },
      {
        "predicate": "director",
        "type": "uid"
      },
      {
        "predicate": "name",
        "type": "string",
        "index": true,
        "tokenizer": [
          "term"
        ]
      },
      {
        "predicate": "release_date",
        "type": "datetime",
        "index": true,
        "tokenizer": [
          "year"
        ]
      },
      {
        "predicate": "revenue",
        "type": "float"
      },
      {
        "predicate": "running_time",
        "type": "int"
      },
      {
        "predicate": "starring",
        "type": "uid"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 445,
      "processing_ns": 647,
      "encoding_ns": 9413292
    },
    "txn": {
      "start_ts": 1,
      "lin_read": {}
    }
  }
}

Starting in a blank directory, could you unzip the file you gave me and run the same commands? I want to see if we get the same result.

yunzhongshu commented 6 years ago

I'v followed your operates, and get the same result with you

yunzhongshu commented 6 years ago

Let me see what's the changes with before

peterstace commented 6 years ago

By the way, I made a mistake in my queries above. It should be '{"drop_all": true}' but I had '{"dropall": true}'.

However, even with that correction I still can't reproduce the problem.

yunzhongshu commented 6 years ago

When i use an empty directories, it's no problem. I can't reproduce the problem too.
And now i know why i can't delete the edge at that time, then I will close this issue. Thank to all of you! Very thank you!

peterstace commented 6 years ago

@yunzhongshu , if you come across the problem again (and can reproduce it), it would be great if you could re-open this ticket. I'm sure there's a problem somewhere in the code (rather than user error), but until we can reproduce there's not much we can do. Thanks! :)

yunzhongshu commented 6 years ago

OK

yunzhongshu commented 6 years ago

zw.zip

I think the zw directory is some wrong in it. When I delete this directory and restart the server, the log appear

" Done schema update predicate:"_predicate_" value_type:STRING list:true "

the upload file is the old directory when the problem happened.

janardhan1993 commented 6 years ago

I was able to reproduce it, i will do a fix. Start server, do drop all and then restart. Schema for predicate is gone.

peterstace commented 6 years ago

@janardhan1993 made a fix merged to master at 3ccced0d