Recreating database with the same instance id

4,050 views
Skip to first unread message

Michael Strickland

unread,
Feb 15, 2017, 4:04:11 PM2/15/17
to Google Cloud SQL discuss
I originally created a database through the Google Cloud web console, and later attempted to replicate the steps using gcloud on the command line for reproducibility.

I found a gcloud command that works when creating a new instance with a different name, but attempting to delete the original instance I made, and recreate it using gcloud failed with the following error:

gcloud beta sql instances create stg-mysql-us-central1 \
  --database-version MYSQL_5_7 \
  --activation-policy ALWAYS \
  --tier db-n1-standard-8 \
  --region us-central1 \
  --replication SYNCHRONOUS \
  --storage-size 200GB \
  --storage-type SSD \
  --storage-auto-increase 
ERROR: (gcloud.beta.sql.instances.create) Project [MY_PROJECT] is the subject of a conflict: The Cloud SQL instance already exists.

This error occurs using the web console as well if you try to create an instance with a name you used previously, even if you have since deleted the instance.

Is this expected behavior? Can we expect that names can be reused after a given amount of time?

I found an old issue on the google bug tracker mentioning the same behavior, but there wasn't any resolution: https://code.google.com/p/googlecloudsql/issues/detail?id=84

Thanks!
Michael

paynen

unread,
Feb 15, 2017, 7:36:52 PM2/15/17
to Google Cloud SQL discuss
Hey Michael,

I can replicate this behaviour on my end and it doesn't seem right. I'll be looking at this with a colleague who is more of a specialist in Cloud SQL and we'll update this thread when we determine what's going on.

Cheers,

Nick
Cloud Platform Community Support

Pia Chamberlain

unread,
Feb 16, 2017, 11:08:03 AM2/16/17
to Google Cloud SQL discuss
This is expected behavior. From https://cloud.google.com/sql/docs/mysql/delete-instance:

You cannot reuse an instance name for up to a week after you have deleted an instance.

paynen

unread,
Feb 16, 2017, 2:20:13 PM2/16/17
to Google Cloud SQL discuss
Thanks Pia. We'll make sure this information is also available on the create-instances page. It might also be useful to include in the error message shown to the users.


Cheers,

Nick
Cloud Platform Community Support

Leonardo Faoro

unread,
Apr 13, 2018, 8:59:28 AM4/13/18
to Google Cloud SQL discuss
I can't use any name containing similar words:

gcloud sql instances create test1 -> The Cloud SQL instance already exists.
gcloud sql instances create test2 -> The Cloud SQL instance already exists.
gcloud sql instances create test123456 -> The Cloud SQL instance already exists.

Is this behavior expected as well?

Pia Chamberlain

unread,
Apr 13, 2018, 12:20:32 PM4/13/18
to Google Cloud SQL discuss
That would not be expected, no. But I can't reproduce that behavior in my project.

Kurt Josephson

unread,
Apr 13, 2018, 1:29:27 PM4/13/18
to google-cloud...@googlegroups.com
My understanding is that these names need to be unique to all CloudSQL instances.  In this case, you might simply be running up against a whole bunch of other users who decided to use the name 'test' for their first instance and the number got auto-incremented.  It's also possible that this got a little out of hand in terms of overuse of 'test' for an instance name so 'test' + {number} might just not be allowed anymore (but that's pure speculation).  

If you try a naming convention like: {your company name}-test and then try to create {your company name}-test1 it should work just fine.  That way you can still specify that it's a test instance, and then use the {your company name} prefix for future production instances.

Hope this was helpful/correct,

-Kurt

p.s.: I'm not affiliated with google in any way, but have been using CloudSQL for a couple years now and I might be one of the users who created a test+number instance when I first started out :)

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/83528c13-c1bd-4ca9-8aac-18dbae5d02a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages