I Want to Do
Use all possible UIDs from 0 → maxUint64
What I Did
My existing dgraph model includes the use of an XID predicate that is an ID that is deterministic and unique in my system. Every insert to dgraph then has to be an upsert that looks up the node that has that XID and uses that variable throughout the mutation:
upsert {
query {
a as var(func: (xid,"myxidvalue"))
}
mutation {
set {
uid(a) "field" "value" .
}
}
}
However, what I want to do is make my use of the internal UID in dgraph detirministic. By taking the hash of my internalID and using the first 64bits of that hash, I can get a number that is of the correct size to use as UID - no problem so far. (other than possible hash collisions… but I want to see if the risk is worth the reward)
To pre-assign those UIDs I run
# curl '127.0.0.1:6080/assign?what=uids&num=18446744073709551615'
{"start":1,"end":18446744073709551615} #its actually alittle harder than this but lets pretend this works
Try to call that endpoint again and you get
# curl '127.0.0.1:6080/assign?what=uids&num=1'
{"errors":[{"message":"Server not initialized","extensions":{"code":"Error"}}]}
ok, bad error, but thats the max for a uint64, lets look past that.
Problem
At this point, I expect to be able to use any uid from 0->maxUint64 on the cluster. But, the alpha believes he only has a handful of UIDs assigned:
# curl --silent 127.0.0.1:8080/state|jq -r '.maxLeaseId'
154253
And the errors my clients get agree:
error encountered performing dgraph request: rpc error: code = Unknown desc = Uid: [2197689836641987139] cannot be greater than lease: [154253]
So, is there a way I can use dgraph and use any available UID? I am sure it would do wonders to my ingestion speed to not have to look up the UID from XID on every single operation.
Dgraph Metadata
dgraph version
[Decoder]: Using assembly version of decoder
Page Size: 4096
Dgraph version : v20.11.0
Dgraph codename : tchalla
Dgraph SHA-256 : 8acb886b24556691d7d74929817a4ac7d9db76bb8b77de00f44650931a16b6ac
Commit SHA-1 : c4245ad55
Commit timestamp : 2020-12-16 15:55:40 +0530
Branch : HEAD
Go version : go1.15.5
jemalloc enabled : true