Rpc error: code = Unimplemented desc = unknown method

I am new to user Docker and attempting to do an import of data I have exported. I am running my Docker container locally and have also installed dgraph via brew.

My docker compose file looks like:

version: "3.2"
services:
  zero:
    image: dgraph/dgraph:latest
    volumes:
      - ./data/zero:/dgraph
    ports:
      - 5080:5080
      - 6080:6080
    restart: on-failure
    command: dgraph zero --my=zero:5080
  alpha:
    image: dgraph/dgraph:latest
    volumes:
      - ./data/alpha:/dgraph
    ports:
      - 8080:8080
      - 9080:9080
    restart: on-failure
    command: dgraph alpha --my=alpha:7080 --zero=zero:5080 --security whitelist=0.0.0.0/0

and when I run the command dgraph live --files data/alpha/export/dgraph.r20082.u1106.2238/g01.json.gz it fails on an infinite loop with 9801 xidmap.go:265] While requesting AssignUids(18464): rpc error: code = Unimplemented desc = unknown method AssignUids for service pb.Zero.

I have checked that the file path is 100% correct. What else could be causing the issue? I have tried to run the dgraph live inside the docker container but then it can only find either the alpha or the zero (I think cause they are in separate containers?).

The full output of the error looks like:

[Decoder]: Using assembly version of decoder
Page Size: 4096
I1107 10:33:52.499873   10249 init.go:107] 

Dgraph version   : -oss
Dgraph codename  : tchalla-3-mod
Dgraph SHA-256   : 48a8f5e764058fca90e40e2a6f3ff9b7dda1e086d5b47a5535c3f01e668bcca5
Commit SHA-1     : 
Commit timestamp : 
Branch           : 
Go version       : go1.17.2
jemalloc enabled : false

For Dgraph official documentation, visit https://dgraph.io/docs/.
For discussions about Dgraph     , visit http://discuss.dgraph.io.

Licensed under the Apache Public License 2.0.
Copyright 2015-2020 Dgraph Labs, Inc.



Running transaction with dgraph endpoint: 127.0.0.1:9080
E1107 10:33:52.509466   10249 xidmap.go:150] Error while getting lease: rpc error: code = Unimplemented desc = unknown method AssignUids for service pb.Zero
Found 1 data file(s) to process
Processing data file "data/alpha/export/dgraph.r20082.u1106.2238/g01.json.gz"
E1107 10:33:52.516534   10249 xidmap.go:265] While requesting AssignUids(18464): rpc error: code = Unimplemented desc = unknown method AssignUids for service pb.Zero
E1107 10:33:52.517521   10249 xidmap.go:265] While requesting AssignUids(18464): rpc error: code = Unimplemented desc = unknown method AssignUids for service pb.Zero
E1107 10:33:52.518718   10249 xidmap.go:265] While requesting AssignUids(18464): rpc error: code = Unimplemented desc = unknown method AssignUids for service pb.Zero
E1107 10:33:52.519739   10249 xidmap.go:265] While requesting AssignUids(18464): rpc error: code = Unimplemented desc = unknown method AssignUids for service pb.Zero

For sure the version installed via Brew(As Darwin isn’t supported anymore) is too old and doesn’t have the extra code needed in the latest.

This also looks like a self built version. Make sure it is using the latest code too.

Also, update the local images in Docker just to be sure.

The docker image is update to date. How can I do this without using brew? As mentioned I have tried running this inside the docker container (via docker exec -it <container name> <command>) but it keeps saying either the zero or alpha can’t be found. Can you provide an example of how I can do this?

You need the standalone image that has all the relevant runtimes bundled together.

  • Make sure Docker engine is running (easiest to do with Docker desktop app)
  • Pull the standalone image: docker pull dgraph/standalone
  • Create a dgraph folder at ~/dgraph (can be anywhere really)
  • Run docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 -p 9080:9080 -p 8000:8000 -v ~/dgraph:/dgraph --name dgraph dgraph/standalone:v21.03.0

The -v ~/dgraph:/dgraph argument maps /dgraph directory inside Docker image to ~/dgraph on your machine. I ran the above command the first time, and in Docker desktop I found the ID of the image that was created, and on subsequent runs I boot up the existing generated image like this:

docker run -it -v ~/dev/dgraph:/dgraph -p 8000:8000 -p 8080:8080 -p 9080:9080 610431a48b7a (610431a48b7a is the id of the image). If you don’t do this it generates a new image every time that uses up hard disk space. Also, notice that I am mapping the volume to ~/dev/dgraph

Who knows what these files are, but I know that my db data is in there. Which means that you can install a different version of Dgraph, and point it at this same volume to load the same database with a different version.

Thank you @BenW, this worked great!

I ended up with the following scripts to get this all working.

Start up a docker image

docker run -it -p 5080:5080 -p 6080:6080 -p 8080:8080 -p 9080:9080 -p 8000:8000 -v $DGRAPH_LOCATION:/dgraph --name dgraph dgraph/standalone:v21.03.0

Run an existing docker image (eg after one has been created)

docker run -it -v $DGRAPH_LOCATION:/dgraph -p 8000:8000 -p 8080:8080 -p 9080:9080 $DOCKER_IMAGE

Export Data

curl -g -X POST "${GRAPHQL_API}"/admin -H "Content-Type: application/json" -d '{"query": "mutation { export(input: { format: \"json\" }) { response { code message } } }"}'

Import Data

docker exec -it "$DOCKER_CONTAINER" dgraph live --files "$BACKUP_FILE_FULL_PATH"

Drop Current Data and Import Data

curl -X POST "${GRAPHQL_API}"/alter -d '{"drop_op": "DATA"}'
docker exec -it "$DOCKER_CONTAINER" dgraph live --files "$BACKUP_FILE_FULL_PATH"

And examples of the variables

GRAPHQL_API=localhost:8080
BACKUP_FILE_FULL_PATH=/Users/<computer-user>/<my-repo>/dgraph/docker/export/<folder-with-export>/g01.json.gz
BACKUP_FILE=export/<folder-with-export>/g01.json.gz
DGRAPH_LOCATION=/Users/<computer>/<my-repo>/dgraph/docker
DOCKER_IMAGE=<docker-image-id>
DOCKER_CONTAINER=<docker-container-id>
1 Like