Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

Google Spanner Emulator - HTTP 500 error on any query

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 -

  1. <name_of_instance> - Replace this with the name of instance you gave to your existing instance.
  2. Emulator must be running before running these commands. You can refer to this documentation to find different ways to start the emulator - https://cloud.google.com/spanner/docs/emulator
question from:https://stackoverflow.com/questions/66060669/google-spanner-emulator-http-500-error-on-any-query

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...