Skip to content

Commit 377eadb

Browse files
authored
fix: skip the copy-instance step if the source is Dolt (#322)
1 parent 588b147 commit 377eadb

File tree

3 files changed

+18
-24
lines changed

3 files changed

+18
-24
lines changed

.github/workflows/replication-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
# source: ['mysql', 'postgres', 'dolt', 'mariadb']
13-
source: ['mysql', 'postgres', 'mariadb']
12+
source: ['postgres', 'mysql', 'mariadb', 'dolt']
1413
steps:
1514
- uses: actions/checkout@v4
1615

devtools/replica-setup-mysql/checker.sh

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,21 +105,20 @@ check_mysql_config() {
105105
return 0
106106
}
107107

108-
# Function to check if source MySQL server is empty
109-
check_if_source_mysql_is_empty() {
110-
# Run the query using mysqlsh and capture the output
111-
OUTPUT=$(mysqlsh --uri "$SOURCE_DSN" $SOURCE_PASSWORD_OPTION --sql -e "SHOW DATABASES;" 2>/dev/null)
112-
113-
check_command "retrieving database list"
114-
115-
# Check if the output contains only the default databases
116-
NON_DEFAULT_DBs=$(echo "$OUTPUT" | grep -cv -E "^(Database|information_schema|mysql|performance_schema|sys)$")
117-
118-
if [[ "$NON_DEFAULT_DBs" -gt 0 ]]; then
108+
# Function to check if the source server could be copied using MySQL Shell
109+
check_if_source_supports_copying_instance() {
110+
# Retrieve the MySQL version using mysqlsh
111+
result=$(mysqlsh --uri="$SOURCE_DSN" $SOURCE_PASSWORD_OPTION --sql -e "SELECT @@global.version_comment")
112+
check_command "retrieving MySQL version comment"
113+
114+
# Currently, Dolt does not support MySQL Shell's copy-instance utility.
115+
# Check if the MySQL version string contains "Dolt"
116+
if echo "$result" | grep -q "Dolt"; then
117+
echo "MySQL Shell's copy-instance utility is not supported by Dolt yet."
119118
return 1
120-
else
121-
return 0
122119
fi
120+
121+
return 0
123122
}
124123

125124
# Function to check if there is ongoing replication on MyDuck Server

devtools/replica-setup-mysql/replica_setup.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,17 @@ echo "Preparing MyDuck Server for replication..."
108108
source prepare.sh
109109
check_command "preparing MyDuck Server for replication"
110110

111-
# Step 4: Check if the MySQL server is empty
112-
echo "Checking if source MySQL server is empty..."
113-
check_if_source_mysql_is_empty
114-
SOURCE_IS_EMPTY=$?
115-
116-
# Step 5: Copy the existing data if the MySQL instance is not empty
117-
if [[ $SOURCE_IS_EMPTY -ne 0 ]]; then
111+
# Step 4: Copy the existing data from the source MySQL instance to MyDuck Server
112+
echo "Checking if source server supports MySQL Shell..."
113+
if check_if_source_supports_copying_instance; then
118114
echo "Copying a snapshot of the MySQL instance to MyDuck Server..."
119115
source snapshot.sh
120116
check_command "copying a snapshot of the MySQL instance"
121117
else
122-
echo "This MySQL instance is empty. Skipping snapshot."
118+
echo "The source server cannot be copied using MySQL Shell. The snapshot step has been skipped."
123119
fi
124120

125-
# Step 6: Establish replication
121+
# Step 5: Establish replication
126122
echo "Starting replication..."
127123
source start_replication.sh
128124
check_command "starting replication"

0 commit comments

Comments
 (0)