2

I want to create two databases in one cloudsql instance. But if it is written in the following way it will result in an error.

resources: - name: test-instance type: sqladmin.v1beta4.instance properties: region: us-central backendType: SECOND_GEN instanceType: CLOUD_SQL_INSTANCE settings: tier: db-f1-micro - name: test_db1 type: sqladmin.v1beta4.database properties: instance: $(ref.test-instance.name) charset: utf8mb4 collation: utf8mb4_general_ci - name: test_db2 type: sqladmin.v1beta4.database properties instance: $(ref.test-instance.name) charset: utf8mb4 collation: utf8mb4_general_ci 

output:

ERROR: (gcloud.deployment-manager.deployments.create) Error in Operation [operation-********] - code: RESOURCE_ERROR location: /deployments/sample-deploy/resources/test_db2 message: '{"ResourceType":"sqladmin.v1beta4.database","ResourceErrorCode":"403","ResourceErrorMessage":{"code":403,"errors":[{"domain":"global","message":"Operation failed because another operation was already in progress.","reason":"operationInProgress"}],"message":"Operation failed because another operation was already in progress.","statusMessage":"Forbidden","requestPath":"https://www.googleapis.com/sql/v1beta4/projects/****/instances/test-instance/databases","httpMethod":"POST"}}' 

Please tell me what to do to resolve the error.

1 Answer 1

2

The error “ResourceErrorCode” is an error which originates with the CloudSQL API.

The issue here is that Deployment Manager will try to run all resource modifications in parallel (unless you specify a dependency between resources). Deployment Manager is a declarative configuration, it will run the deployments in parallel either they are independent of each other or not.

In this specific case, CloudSQL is not able to create two databases at the same time. This is why you are seeing the error message: Operation failed because another operation was already in progress.

There can be only one pending operation at a given point of time because of the inherent system architecture. This is a limitation on the concurrent writes to a CloudSQL database.

To resolve this issue, you will have to create the two databases in sequence, not in parallel.

For more information on how to do so, you may consult the documentation on this matter.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.