Skip to content

Commit 5a141ae

Browse files
committed
determine and verify OceanBase connection
1 parent 6c080b4 commit 5a141ae

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

go/base/utils.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package base
77

88
import (
9+
"errors"
910
"fmt"
1011
"os"
1112
"regexp"
@@ -62,6 +63,10 @@ func StringContainsAll(s string, substrings ...string) bool {
6263
}
6364

6465
func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig, migrationContext *MigrationContext, name string) (string, error) {
66+
if err := validateOceanBaseConnection(db, migrationContext); err != nil {
67+
return "", err
68+
}
69+
6570
versionQuery := `select @@global.version`
6671

6772
var version string
@@ -102,3 +107,26 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig,
102107
return "", fmt.Errorf("Unexpected database port reported: %+v / extra_port: %+v", port, extraPort)
103108
}
104109
}
110+
111+
func validateOceanBaseConnection(db *gosql.DB, migrationContext *MigrationContext) error {
112+
versionCommentQuery := `select @@global.version_comment`
113+
var versionComment string
114+
if err := db.QueryRow(versionCommentQuery).Scan(&versionComment); err != nil {
115+
return nil
116+
}
117+
if !strings.Contains(versionComment, "OceanBase") {
118+
return nil
119+
}
120+
121+
migrationContext.OceanBase = true
122+
123+
enableLockPriorityQuery := `select value from oceanbase.GV$OB_PARAMETERS where name='enable_lock_priority'`
124+
var enableLockPriority bool
125+
if err := db.QueryRow(enableLockPriorityQuery).Scan(&enableLockPriority); err != nil {
126+
return err
127+
}
128+
if !enableLockPriority {
129+
return errors.New("system parameter 'enable_lock_priority' should be true to support cut-over")
130+
}
131+
return nil
132+
}

go/cmd/gh-ost/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ func main() {
8686
flag.BoolVar(&migrationContext.AliyunRDS, "aliyun-rds", false, "set to 'true' when you execute on Aliyun RDS.")
8787
flag.BoolVar(&migrationContext.GoogleCloudPlatform, "gcp", false, "set to 'true' when you execute on a 1st generation Google Cloud Platform (GCP).")
8888
flag.BoolVar(&migrationContext.AzureMySQL, "azure", false, "set to 'true' when you execute on Azure Database on MySQL.")
89-
flag.BoolVar(&migrationContext.OceanBase, "oceanbase", false, "set to 'true' when you execute on OceanBase")
9089

9190
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
9291
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust")

0 commit comments

Comments
 (0)