I have two Cloud SQL PostgreSQL instances : one master and one read-only replica.
When I try to export the datas from the read-only replica to a given bucket using the Cloud SQL v1beta4 Export API (https://cloud.google.com/sql/docs/postgres/admin-api/v1beta4/instances/export), with the following request body :
{
"exportContext": {
"kind": "sql#exportContext",
"fileType": "CSV",
"uri": "gs://bucket_uri",
"databases": [
"db_name"
],
"csvExportOptions": {
"selectQuery": "SELECT * FROM db_name.table_name"
}
}
}
I get the following error :
{
"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"
}
]
}
}
But when I use the master instance, everything works fine.
I also did the same thing but with a Cloud SQL MySQL instance, and the export API was working well on the read-only replica, that's why I'm surprised it's not working on a PostgreSQL read-only replica instance.
I don't want to plug my export on the master instance as the instance is already busy enough. Do you have encountered the same kind of issue ? Any idea how to solve this ?