Google 云 SQL - 导出 API - PostgreSQL:错误 400 请求的操作对只读副本实例无效
Google Cloud SQL - Export API - PostgreSQL : Error 400 The requested operation is not valid for a read-replica instance
我有两个 Cloud SQL PostgreSQL 实例:一个主实例和一个只读副本。
当我尝试使用 Cloud SQL v1beta4 Export API (https://cloud.google.com/sql/docs/postgres/admin-api/v1beta4/instances/export) 将数据从只读副本导出到给定存储桶时,请求正文如下:
{
"exportContext": {
"kind": "sql#exportContext",
"fileType": "CSV",
"uri": "gs://bucket_uri",
"databases": [
"db_name"
],
"csvExportOptions": {
"selectQuery": "SELECT * FROM db_name.table_name"
}
}
}
我收到以下错误:
{
"error": {
"code": 400,
"message": "The requested operation is not valid for a read-replica instance.",
"errors": [
{
"message": "The requested operation is not valid for a read-replica instance.",
"domain": "global",
"reason": "errorReadReplicaInvalidOperation"
}
]
}
}
但是当我使用主实例时,一切正常。
我也做了同样的事情,但使用的是 Cloud SQL MySQL 实例,并且导出 API 在只读副本上运行良好,这就是为什么我很惊讶它不能在 PostgreSQL 只读副本实例上工作。
我不想在主实例上插入导出,因为该实例已经很忙了。你遇到过同样的问题吗?知道如何解决这个问题吗?
根据官方文档link。
Note: You cannot export to a CSV file from a read replica instance.
The export operation creates an export user and grants that user
select permissions on the database the user wants to export. Since
read replica instances run in read only mode, these operations fail.
由于此实例是一个副本,因此对它的任何交易都将被视为只读。基本上,对于只读约束,授予权限将 fail.The 当前的解决方法是在 MASTER 实例中进行导出,而不是像您提到的那样在 REPLICA 中进行导出。
我有两个 Cloud SQL PostgreSQL 实例:一个主实例和一个只读副本。
当我尝试使用 Cloud SQL v1beta4 Export API (https://cloud.google.com/sql/docs/postgres/admin-api/v1beta4/instances/export) 将数据从只读副本导出到给定存储桶时,请求正文如下:
{
"exportContext": {
"kind": "sql#exportContext",
"fileType": "CSV",
"uri": "gs://bucket_uri",
"databases": [
"db_name"
],
"csvExportOptions": {
"selectQuery": "SELECT * FROM db_name.table_name"
}
}
}
我收到以下错误:
{
"error": {
"code": 400,
"message": "The requested operation is not valid for a read-replica instance.",
"errors": [
{
"message": "The requested operation is not valid for a read-replica instance.",
"domain": "global",
"reason": "errorReadReplicaInvalidOperation"
}
]
}
}
但是当我使用主实例时,一切正常。
我也做了同样的事情,但使用的是 Cloud SQL MySQL 实例,并且导出 API 在只读副本上运行良好,这就是为什么我很惊讶它不能在 PostgreSQL 只读副本实例上工作。
我不想在主实例上插入导出,因为该实例已经很忙了。你遇到过同样的问题吗?知道如何解决这个问题吗?
根据官方文档link。
Note: You cannot export to a CSV file from a read replica instance. The export operation creates an export user and grants that user select permissions on the database the user wants to export. Since read replica instances run in read only mode, these operations fail.
由于此实例是一个副本,因此对它的任何交易都将被视为只读。基本上,对于只读约束,授予权限将 fail.The 当前的解决方法是在 MASTER 实例中进行导出,而不是像您提到的那样在 REPLICA 中进行导出。