Bug #99186 CLONE INSTANCE - ERROR 1007 (HY000): Can't create database
Submitted: 6 Apr 2020 6:57 Modified: 7 Apr 2020 12:30
Reporter: Chelluru Vidyadhar Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Clone Plugin Severity:S4 (Feature request)
Version:8.0.17,8.0.18 OS:Any
Assigned to: CPU Architecture:Any

[6 Apr 2020 6:57] Chelluru Vidyadhar
Description:
When we are using CLONE INSTANCE command (clone plugin) with DATA DIRECTORY option, mentioned directory should not exist and MySQL will try to create the directory. In case the directory exists then we will receive below error.

ERROR 1007 (HY000): Can't create database '/tmp/clonetest_from_ec2'; database exists

When CLONE INSTANCE commands failed in any of the prechecks then it leaves the created directory and subsequent CLONE INSTANCE command will fail. 

>> Consider to remove the directory when any precheck operation fails or create the directory only after prechecks are complete. 

How to repeat:
Just run CLONE INSTANCE command twice.

CLONE INSTANCE FROM 'donor_clone_user'@'donor_host':3306 IDENTIFIED BY 'password' DATA DIRECTORY='/home/mysql/clonetest';

mysql> CLONE INSTANCE FROM 'donor_clone_user'@'donor_host':3306 IDENTIFIED BY 'password' DATA DIRECTORY='/home/mysql/clonetest';
ERROR 3864 (HY000): Clone Donor MySQL version: 8.0.18 is different from Recipient MySQL version 8.0.17.

mysql> CLONE INSTANCE FROM 'donor_clone_user'@'donor_host':3306 IDENTIFIED BY 'password' DATA DIRECTORY='/home/mysql/clonetest';
ERROR 1007 (HY000): Can't create database '/home/mysql/clonetest'; database exists

Suggested fix:
I understand that we place clone_status and clone_progress files in side #clone directory which reside inside mentioned DATA DIRECTORY. All information/errors related failed CLONEs can be stored in performance schema tables.
[6 Apr 2020 6:58] Chelluru Vidyadhar
Updated Synopsis.
[7 Apr 2020 12:30] MySQL Verification Team
Hi Mr. Vidyadhar,

Thank you for your feature request.

As far as I understand, you are looking for a new clause in the CLONE INSTANCE syntax, that will remove or re-use already existing schema.

I think that this request makes sense.

Verified as reported.