add support for rocksdb · github/gh-ost@da35142 · GitHub
Skip to content

Commit da35142

Browse files
author
lukelewang
committed
add support for rocksdb
1 parent 094909f commit da35142

6 files changed

Lines changed: 84 additions & 71 deletions

File tree

‎go/base/context.go‎

Lines changed: 5 additions & 6 deletions

‎go/cmd/gh-ost/main.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ func acceptSignals(migrationContext *base.MigrationContext) {
4747
// main is the application's entry point. It will either spawn a CLI or HTTP interfaces.
4848
func main() {
4949
migrationContext := base.NewMigrationContext()
50-
host := flag.String("host", "127.0.0.1", "MySQL hostname (preferably a replica, not the master)")
51-
port := flag.Int("port", 3306, "MySQL port (preferably a replica, not the master)")
52-
timeout := flag.Float64("mysql-timeout", 0.0, "Connect, read and write timeout for MySQL")
50+
flag.StringVar(&migrationContext.InspectorConnectionConfig.Key.Hostname, "host", "127.0.0.1", "MySQL hostname (preferably a replica, not the master)")
5351
flag.StringVar(&migrationContext.AssumeMasterHostname, "assume-master-host", "", "(optional) explicitly tell gh-ost the identity of the master. Format: some.host.com[:port] This is useful in master-master setups where you wish to pick an explicit master, or in a tungsten-replicator where gh-ost is unable to determine the master")
52+
flag.IntVar(&migrationContext.InspectorConnectionConfig.Key.Port, "port", 3306, "MySQL port (preferably a replica, not the master)")
53+
flag.Float64Var(&migrationContext.InspectorConnectionConfig.Timeout, "mysql-timeout", 0.0, "Connect, read and write timeout for MySQL")
5454
flag.StringVar(&migrationContext.CliUser, "user", "", "MySQL user")
5555
flag.StringVar(&migrationContext.CliPassword, "password", "", "MySQL password")
5656
flag.StringVar(&migrationContext.CliMasterUser, "master-user", "", "MySQL user on master, if different from that on replica. Requires --assume-master-host")
@@ -183,7 +183,7 @@ func main() {
183183
migrationContext.Log.SetLevel(log.ERROR)
184184
}
185185

186-
if err := migrationContext.SetConnectionConfig(*storageEngine, *host, *port, *timeout); err != nil {
186+
if err := migrationContext.SetConnectionConfig(*storageEngine); err != nil {
187187
migrationContext.Log.Fatale(err)
188188
}
189189

‎go/mysql/connection.go‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@ type ConnectionConfig struct {
2929
ImpliedKey *InstanceKey
3030
tlsConfig *tls.Config
3131
Timeout float64
32-
transactionIsolation string
32+
TransactionIsolation string
3333
}
3434

35-
func NewConnectionConfig(transactionIsolation string) *ConnectionConfig {
35+
func NewConnectionConfig() *ConnectionConfig {
3636
config := &ConnectionConfig{
37-
Key: InstanceKey{},
38-
transactionIsolation: transactionIsolation,
37+
Key: InstanceKey{},
3938
}
4039
config.ImpliedKey = &config.Key
4140
return config
@@ -44,11 +43,12 @@ func NewConnectionConfig(transactionIsolation string) *ConnectionConfig {
4443
// DuplicateCredentials creates a new connection config with given key and with same credentials as this config
4544
func (this *ConnectionConfig) DuplicateCredentials(key InstanceKey) *ConnectionConfig {
4645
config := &ConnectionConfig{
47-
Key: key,
48-
User: this.User,
49-
Password: this.Password,
50-
tlsConfig: this.tlsConfig,
51-
Timeout: this.Timeout,
46+
Key: key,
47+
User: this.User,
48+
Password: this.Password,
49+
tlsConfig: this.tlsConfig,
50+
Timeout: this.Timeout,
51+
TransactionIsolation: this.TransactionIsolation,
5252
}
5353
config.ImpliedKey = &config.Key
5454
return config
@@ -127,7 +127,7 @@ func (this *ConnectionConfig) GetDBUri(databaseName string) string {
127127
"charset=utf8mb4,utf8,latin1",
128128
"interpolateParams=true",
129129
fmt.Sprintf("tls=%s", tlsOption),
130-
fmt.Sprintf("transaction_isolation=%q", this.transactionIsolation),
130+
fmt.Sprintf("transaction_isolation=%q", this.TransactionIsolation),
131131
fmt.Sprintf("timeout=%fs", this.Timeout),
132132
fmt.Sprintf("readTimeout=%fs", this.Timeout),
133133
fmt.Sprintf("writeTimeout=%fs", this.Timeout),

‎go/mysql/connection_test.go‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,26 @@ func init() {
2222
}
2323

2424
func TestNewConnectionConfig(t *testing.T) {
25-
c := NewConnectionConfig(transactionIsolation)
25+
c := NewConnectionConfig()
2626
test.S(t).ExpectEquals(c.Key.Hostname, "")
2727
test.S(t).ExpectEquals(c.Key.Port, 0)
2828
test.S(t).ExpectEquals(c.ImpliedKey.Hostname, "")
2929
test.S(t).ExpectEquals(c.ImpliedKey.Port, 0)
3030
test.S(t).ExpectEquals(c.User, "")
3131
test.S(t).ExpectEquals(c.Password, "")
32+
test.S(t).ExpectEquals(c.TransactionIsolation, "")
3233
}
3334

3435
func TestDuplicateCredentials(t *testing.T) {
35-
c := NewConnectionConfig(transactionIsolation)
36+
c := NewConnectionConfig()
3637
c.Key = InstanceKey{Hostname: "myhost", Port: 3306}
3738
c.User = "gromit"
3839
c.Password = "penguin"
3940
c.tlsConfig = &tls.Config{
4041
InsecureSkipVerify: true,
4142
ServerName: "feathers",
4243
}
44+
c.TransactionIsolation = transactionIsolation
4345

4446
dup := c.DuplicateCredentials(InstanceKey{Hostname: "otherhost", Port: 3310})
4547
test.S(t).ExpectEquals(dup.Key.Hostname, "otherhost")
@@ -49,13 +51,15 @@ func TestDuplicateCredentials(t *testing.T) {
4951
test.S(t).ExpectEquals(dup.User, "gromit")
5052
test.S(t).ExpectEquals(dup.Password, "penguin")
5153
test.S(t).ExpectEquals(dup.tlsConfig, c.tlsConfig)
54+
test.S(t).ExpectEquals(dup.TransactionIsolation, c.TransactionIsolation)
5255
}
5356

5457
func TestDuplicate(t *testing.T) {
55-
c := NewConnectionConfig(transactionIsolation)
58+
c := NewConnectionConfig()
5659
c.Key = InstanceKey{Hostname: "myhost", Port: 3306}
5760
c.User = "gromit"
5861
c.Password = "penguin"
62+
c.TransactionIsolation = transactionIsolation
5963

6064
dup := c.Duplicate()
6165
test.S(t).ExpectEquals(dup.Key.Hostname, "myhost")
@@ -64,26 +68,29 @@ func TestDuplicate(t *testing.T) {
6468
test.S(t).ExpectEquals(dup.ImpliedKey.Port, 3306)
6569
test.S(t).ExpectEquals(dup.User, "gromit")
6670
test.S(t).ExpectEquals(dup.Password, "penguin")
71+
test.S(t).ExpectEquals(dup.TransactionIsolation, transactionIsolation)
6772
}
6873

6974
func TestGetDBUri(t *testing.T) {
70-
c := NewConnectionConfig(transactionIsolation)
75+
c := NewConnectionConfig()
7176
c.Key = InstanceKey{Hostname: "myhost", Port: 3306}
7277
c.User = "gromit"
7378
c.Password = "penguin"
7479
c.Timeout = 1.2345
80+
c.TransactionIsolation = transactionIsolation
7581

7682
uri := c.GetDBUri("test")
7783
test.S(t).ExpectEquals(uri, `gromit:penguin@tcp(myhost:3306)/test?autocommit=true&charset=utf8mb4,utf8,latin1&interpolateParams=true&tls=false&transaction_isolation="REPEATABLE-READ"&timeout=1.234500s&readTimeout=1.234500s&writeTimeout=1.234500s`)
7884
}
7985

8086
func TestGetDBUriWithTLSSetup(t *testing.T) {
81-
c := NewConnectionConfig(transactionIsolation)
87+
c := NewConnectionConfig()
8288
c.Key = InstanceKey{Hostname: "myhost", Port: 3306}
8389
c.User = "gromit"
8490
c.Password = "penguin"
8591
c.Timeout = 1.2345
8692
c.tlsConfig = &tls.Config{}
93+
c.TransactionIsolation = transactionIsolation
8794

8895
uri := c.GetDBUri("test")
8996
test.S(t).ExpectEquals(uri, `gromit:penguin@tcp(myhost:3306)/test?autocommit=true&charset=utf8mb4,utf8,latin1&interpolateParams=true&tls=ghost&transaction_isolation="REPEATABLE-READ"&timeout=1.234500s&readTimeout=1.234500s&writeTimeout=1.234500s`)

‎localtests/test.sh‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tests_path=$(dirname $0)
1111
test_logfile=/tmp/gh-ost-test.log
1212
default_ghost_binary=/tmp/gh-ost-test
1313
ghost_binary=""
14+
storage_engine=innodb
1415
exec_command_file=/tmp/gh-ost-test.bash
1516
ghost_structure_output_file=/tmp/gh-ost-test.ghost.structure.sql
1617
orig_content_output_file=/tmp/gh-ost-test.orig.content.csv
@@ -24,12 +25,13 @@ replica_port=
2425
original_sql_mode=
2526

2627
OPTIND=1
27-
while getopts "b:" OPTION
28+
while getopts "b:s:" OPTION
2829
do
2930
case $OPTION in
3031
b)
31-
ghost_binary="$OPTARG"
32-
;;
32+
ghost_binary="$OPTARG";;
33+
s)
34+
storage_engine="$OPTARG";;
3335
esac
3436
done
3537
shift $((OPTIND-1))
@@ -158,7 +160,8 @@ test_single() {
158160
--assume-master-host=${master_host}:${master_port}
159161
--database=test \
160162
--table=gh_ost_test \
161-
--alter='engine=innodb' \
163+
--storage-engine=${storage_engine} \
164+
--alter='engine=${storage_engine}' \
162165
--exact-rowcount \
163166
--assume-rbr \
164167
--initially-drop-old-table \

‎script/cibuild-gh-ost-replica-tests‎

Lines changed: 46 additions & 42 deletions

0 commit comments

Comments
 (0)