I installed a spanner emulator yesterday and it was successfully returning me the results of my queries like gcloud spanner databases list --instance=test-instance
But since I restarted my machine, I am seeing this particular error when I try to do a databases list, or any other query for that matter. It is returning the following error in every case-
gcloud spanner databases list --instance=test-instance
ERROR: (gcloud.spanner.databases.list) HttpError accessing <http://localhost:9020/v1/projects/test-project/instances/test-instance/databases?alt=json&pageSize=100>: response: <{'date': 'Fri, 05 Feb 2021 09:18:12 GMT', u'status': 500, 'content-length': '44', 'content-type': 'application/json'}>, content <{"error": "failed to marshal error message"}>
This may be due to network connectivity issues. Please check your network settings, and the status of the service you are trying to reach.
Can anyone please tell me what might be the reason for the same?
Note - I tried starting the emulator using both the CLI as well as Docker, but none worked. I am getting the following output from both the methods, which leads me to believe that the emulator is starting up correctly.
gcloud beta emulators spanner start
Executing: docker run -p 127.0.0.1:9010:9010 -p 127.0.0.1:9020:9020 gcr.io/cloud-spanner-emulator/emulator:1.1.1
[cloud-spanner-emulator] 2021/02/05 09:10:41 gateway.go:140: Cloud Spanner emulator running.
[cloud-spanner-emulator] 2021/02/05 09:10:41 gateway.go:141: REST server listening at 0.0.0.0:9020
[cloud-spanner-emulator] 2021/02/05 09:10:41 gateway.go:142: gRPC server listening at 0.0.0.0:9010
Update
As per @Hoilong's answer below. Recreating the spanner instance worked fine. Following are the commands which were run to recreate the instance -
gcloud spanner instances delete <name_of_instance>
And then
gcloud spanner instances create <name_of_instance> --config=emulator-config --description="Test Instance" --nodes=1
Note -
Emulator is not like a local instance. According to the public documentation:
As the emulator stores data only in memory, it will not persist data across runs.
What happened here is that after restart, all the data (not just the data stored in the database, but also the instance/database) are gone. You just have to recreate the instance/database.