【问题标题】:Google Spanner Emulator - HTTP 500 error on any queryGoogle Spanner Emulator - 任何查询都出现 HTTP 500 错误
【发布时间】:2021-02-05 09:24:25
【问题描述】:

我昨天安装了一个扳手模拟器,它成功地返回了我的查询结果,例如gcloud spanner databases list --instance=test-instance

但是由于我重新启动了我的机器,当我尝试执行数据库列表或任何其他与此相关的查询时,我看到了这个特定的错误。它在每种情况下都返回以下错误-

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.

谁能告诉我这可能是什么原因?

注意 - 我尝试使用 CLI 和 Docker 启动模拟器,但都没有成功。我从这两种方法中都得到了以下输出,这让我相信模拟器正在正确启动。

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

更新


根据下面@Hoilong 的回答。重新创建扳手实例工作正常。以下是为重新创建实例而运行的命令 -

gcloud spanner instances delete <name_of_instance>

然后

gcloud spanner instances create <name_of_instance> --config=emulator-config --description="Test Instance" --nodes=1

注意 -

  1. - 将此替换为您为现有实例指定的实例名称。
  2. 在运行这些命令之前必须运行模拟器。您可以参考此文档以找到启动模拟器的不同方法 - https://cloud.google.com/spanner/docs/emulator

【问题讨论】:

  • 这种情况只发生在这个特定的实例上吗?作为测试,您是否尝试过创建第二个实例并使用该实例?

标签: google-cloud-platform google-cloud-spanner google-cloud-spanner-emulator


【解决方案1】:

模拟器不像本地实例。根据公开文件:

由于模拟器仅将数据存储在内存中,因此不会在运行期间持久保存数据。

这里发生的情况是,重启后,所有数据(不仅仅是存储在数据库中的数据,还包括实例/数据库)都消失了。您只需要重新创建实例/数据库。

【讨论】:

  • 谢谢@Hoilong。重新创建实例有效。对于在本地机器上尝试它的任何人。您需要运行的只是首先删除现有 spanner 实例然后创建新实例的命令。将更新问题描述以获得更好的格式。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多