Skip to content

Commit

Permalink
fix: skip the copy-instance step if the source is Dolt (#322)
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyang01 authored Dec 25, 2024
1 parent 588b147 commit 377eadb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/replication-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# source: ['mysql', 'postgres', 'dolt', 'mariadb']
source: ['mysql', 'postgres', 'mariadb']
source: ['postgres', 'mysql', 'mariadb', 'dolt']
steps:
- uses: actions/checkout@v4

Expand Down
25 changes: 12 additions & 13 deletions devtools/replica-setup-mysql/checker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,20 @@ check_mysql_config() {
return 0
}

# Function to check if source MySQL server is empty
check_if_source_mysql_is_empty() {
# Run the query using mysqlsh and capture the output
OUTPUT=$(mysqlsh --uri "$SOURCE_DSN" $SOURCE_PASSWORD_OPTION --sql -e "SHOW DATABASES;" 2>/dev/null)

check_command "retrieving database list"

# Check if the output contains only the default databases
NON_DEFAULT_DBs=$(echo "$OUTPUT" | grep -cv -E "^(Database|information_schema|mysql|performance_schema|sys)$")

if [[ "$NON_DEFAULT_DBs" -gt 0 ]]; then
# Function to check if the source server could be copied using MySQL Shell
check_if_source_supports_copying_instance() {
# Retrieve the MySQL version using mysqlsh
result=$(mysqlsh --uri="$SOURCE_DSN" $SOURCE_PASSWORD_OPTION --sql -e "SELECT @@global.version_comment")
check_command "retrieving MySQL version comment"

# Currently, Dolt does not support MySQL Shell's copy-instance utility.
# Check if the MySQL version string contains "Dolt"
if echo "$result" | grep -q "Dolt"; then
echo "MySQL Shell's copy-instance utility is not supported by Dolt yet."
return 1
else
return 0
fi

return 0
}

# Function to check if there is ongoing replication on MyDuck Server
Expand Down
14 changes: 5 additions & 9 deletions devtools/replica-setup-mysql/replica_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,17 @@ echo "Preparing MyDuck Server for replication..."
source prepare.sh
check_command "preparing MyDuck Server for replication"

# Step 4: Check if the MySQL server is empty
echo "Checking if source MySQL server is empty..."
check_if_source_mysql_is_empty
SOURCE_IS_EMPTY=$?

# Step 5: Copy the existing data if the MySQL instance is not empty
if [[ $SOURCE_IS_EMPTY -ne 0 ]]; then
# Step 4: Copy the existing data from the source MySQL instance to MyDuck Server
echo "Checking if source server supports MySQL Shell..."
if check_if_source_supports_copying_instance; then
echo "Copying a snapshot of the MySQL instance to MyDuck Server..."
source snapshot.sh
check_command "copying a snapshot of the MySQL instance"
else
echo "This MySQL instance is empty. Skipping snapshot."
echo "The source server cannot be copied using MySQL Shell. The snapshot step has been skipped."
fi

# Step 6: Establish replication
# Step 5: Establish replication
echo "Starting replication..."
source start_replication.sh
check_command "starting replication"

0 comments on commit 377eadb

Please sign in to comment.