forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 13
WIP: ApplySchema to run online schema changes via gh-ost
#67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
f287663
vttablet: stateManager tests WIP
sougou 5b99487
tabletserver: create new ReplTracker skeleton
sougou 2a97a0e
vttablet: move hc flags to tabletenv.TabletConfig
sougou 4b08c81
vttablet: type safe Seconds instead of float64
sougou 3af6df5
vttablet: enable_replication_reporter -> tabletenv
sougou 6d65f9f
vttablet: saving work. need mysqld in tabletserver
sougou 4776c74
vttablet: add mysqld to tabletserver
sougou 7098531
vttablet: ReplTracker functional
sougou cddd0de
vttablet: switch to use replTracker
sougou 52d6b06
vttablet: tests for ReplTracker
sougou fff8340
vttablet: new healthStreamer
sougou e1a1170
vttablet: wire-up most of healthStreamer
sougou addfd0e
vttablet: streamHealth wired up
sougou 020b2e7
vttablet: status page uses healthStreamer
sougou 9dee129
vttablet: VREngine retries if Open fails
sougou 5f968fc
tm: preparing to delete healthcheck
sougou b4f2207
vttablet: trying a different heathcheck
sougou efcf8b3
vttablet: delete old broken health tests
sougou 290ea36
vttablet: make BACKUP StateNotConnected
sougou 2f22ad3
vttablet: fix tabletserver repl health & tests
sougou ea790b5
vttablet: relpManager initial code
sougou 109aab6
vttablet: fix tabletmanager tests
sougou 6dd319d
vttablet: fix more tests
sougou ff9dd14
vttablet: replManager unit tests
sougou 30f98a8
vttablet: delete deprecated code
sougou e8dba28
vttablet: fix after rebase
sougou 42fa9ad
vttablet: move gracePeriod to TabletConfig
sougou c3bb83e
vttablet: SetServingType handles alsoAllow
sougou 8e23766
vttablet: tmState initial cut
sougou 453497f
vttablet: use tmState
sougou 991dde7
vttablet: create a separate displayState
sougou 124b245
vttablet: check replication on open
sougou 017f2a9
vttablet: remove spurious sleep in binlog_watcher
sougou 6af2b16
vttablet: fix after rebase
sougou 9f2ea0a
vttablet: stateManager details on status page
sougou 0babfd4
vttablet: healthStreamer details on status page
sougou b1adbdc
vttablet: remove tm's status export
sougou 1ba7b63
vttablet: export reason to status
sougou e88b4f5
endtoend: start removing InitTablet calls
sougou 635bb2f
vttablet: log repl health changes
sougou 9632050
end2end: fix vertical_split_test
sougou 7189cb8
end2end: sharding test fixes
sougou a2ec700
end2end: fix shardedrecovery test
sougou a50662a
end2end: speed up tests
sougou 8ae485d
end2end: remove most InitTablet and CreateDB calls
sougou 09228c6
vttablet: tracker closed on non-serving
sougou d386dc4
end2end: InitTablet removed: reparent & cellalias
sougou 4029435
vttablet: VREngine retry tests
sougou 1c3de85
vttablet: test for alsoAllow
sougou d3f4fef
vttablet: tm_state tests
sougou b716b97
vttablet: add polish
sougou 95deb90
gh-ost credentials
shlomi-noach 77955f7
gh-ost credentials
shlomi-noach 1e89dd8
setting up ghost and handler
shlomi-noach a429c7b
executor for gh-ost
shlomi-noach a622661
support OnlineSchemaChange on schema/apply
shlomi-noach f7c1323
support crearin tempdir and file
shlomi-noach a4584e6
generate gh-ost wrapper script on the fly. Use temp dir
shlomi-noach a83e4c6
ApplyOnlineSchemaChange refactored into Controller
shlomi-noach 483fc51
cleanup
shlomi-noach bebfb01
cleanup and comments
shlomi-noach 6e7fc2f
typo
shlomi-noach 1cd2d47
TODO
shlomi-noach 4496d54
introducing query hint: VitessOnlineDDLHint
shlomi-noach 78aad71
IsOnlineSchemaDDL analysis
shlomi-noach 73ad39b
more explicit hint, also comment suggesting it's a hack for now
shlomi-noach 4d3fbf3
building an OnlineDDL plan
shlomi-noach 1d27705
merged master
shlomi-noach 39f642f
remove online-schema-change code from vtgate and analyzer
shlomi-noach 6df82bd
Revert "remove online-schema-change code from vtgate and analyzer"
shlomi-noach 1346284
online_schema_change manages UUID and writes OSC request to global topo
shlomi-noach 3d623eb
vtctl/tablet_executor write online schema change request to global topo
shlomi-noach 015d974
vtgate intercepts ALTER TABLE statements and writes an online schema …
shlomi-noach 7299301
refactored TopoPath() function
shlomi-noach 5a89653
refactor: applying _vt.schema_migrations schema
shlomi-noach 58b9a3a
refactor: naming
shlomi-noach e329bda
vtctld review migration requests, explodes per shard
shlomi-noach fa0e551
adding uuid gomod
shlomi-noach c551a03
fixed merge conflict
shlomi-noach 2741151
vtctld runs schema checks
shlomi-noach 225bc3b
reporting back UUID in response to ALTER TABLE statement
shlomi-noach d13b41b
/schema-migration/report-status API endpoint
shlomi-noach cafb9c1
Using latest gh-ost release from openark org
shlomi-noach 079a987
sqltypes.Result supports NamedResults, via Named() function
shlomi-noach 3393fa5
GetInt64(), GetUint64() convenience methods
shlomi-noach 2336eac
Row() convenience method
shlomi-noach 115de10
convenience methods in RowNamedValues
shlomi-noach 759e76d
ToBool() conveniene method
shlomi-noach 718e890
cleanup, undo adding fields to proto.SchemaChange
shlomi-noach fbd2457
cleanup, undo adding fields to proto.SchemaChange
shlomi-noach c78021c
Cleanup, undo and remove logic from tablet manager path
shlomi-noach 142f06f
Cleanup, undo and remove logic from tablet manager path
shlomi-noach e87faa5
while still WIP, further logic into online ddl executor
shlomi-noach 5029bd7
updating migration status and timestamp in response to API call
shlomi-noach bb4b328
minor cleanup and rename
shlomi-noach 8481c3c
cleanup: remove unused code
shlomi-noach 2b075df
Autogenerate gh-ost account and privileges
shlomi-noach de9b561
no need for gh-ost account in config/rice
shlomi-noach a8ae617
remove debug info
shlomi-noach 6a37b43
remove debug info
shlomi-noach 23b60b5
gh-ost password stored in environment variable, no longer visible as …
shlomi-noach 0822dd0
provide gh-ost with DBName
shlomi-noach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| /* | ||
| Copyright 2019 The Vitess Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package sqltypes | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| querypb "vitess.io/vitess/go/vt/proto/query" | ||
| ) | ||
|
|
||
| var ( | ||
| // ErrNoSuchField indicates a search for a value by an unknown field/column name | ||
| ErrNoSuchField = errors.New("No such field in RowNamedValues") | ||
| ) | ||
|
|
||
| // RowNamedValues contains a row's values as a map based on Field (aka table column) name | ||
| type RowNamedValues map[string]Value | ||
|
|
||
| // ToString returns the named field as string | ||
| func (r RowNamedValues) ToString(fieldName string) (string, error) { | ||
| if v, ok := r[fieldName]; ok { | ||
| return v.ToString(), nil | ||
| } | ||
| return "", ErrNoSuchField | ||
| } | ||
|
|
||
| // AsString returns the named field as string, or default value if nonexistent/error | ||
| func (r RowNamedValues) AsString(fieldName string, def string) string { | ||
| if v, err := r.ToString(fieldName); err == nil { | ||
| return v | ||
| } | ||
| return def | ||
| } | ||
|
|
||
| // ToInt64 returns the named field as int64 | ||
| func (r RowNamedValues) ToInt64(fieldName string) (int64, error) { | ||
| if v, ok := r[fieldName]; ok { | ||
| return v.ToInt64() | ||
| } | ||
| return 0, ErrNoSuchField | ||
| } | ||
|
|
||
| // AsInt64 returns the named field as int64, or default value if nonexistent/error | ||
| func (r RowNamedValues) AsInt64(fieldName string, def int64) int64 { | ||
| if v, err := r.ToInt64(fieldName); err == nil { | ||
| return v | ||
| } | ||
| return def | ||
| } | ||
|
|
||
| // ToUint64 returns the named field as uint64 | ||
| func (r RowNamedValues) ToUint64(fieldName string) (uint64, error) { | ||
| if v, ok := r[fieldName]; ok { | ||
| return v.ToUint64() | ||
| } | ||
| return 0, ErrNoSuchField | ||
| } | ||
|
|
||
| // AsUint64 returns the named field as uint64, or default value if nonexistent/error | ||
| func (r RowNamedValues) AsUint64(fieldName string, def uint64) uint64 { | ||
| if v, err := r.ToUint64(fieldName); err == nil { | ||
| return v | ||
| } | ||
| return def | ||
| } | ||
|
|
||
| // ToBool returns the named field as bool | ||
| func (r RowNamedValues) ToBool(fieldName string) (bool, error) { | ||
| if v, ok := r[fieldName]; ok { | ||
| return v.ToBool() | ||
| } | ||
| return false, ErrNoSuchField | ||
| } | ||
|
|
||
| // AsBool returns the named field as bool, or default value if nonexistent/error | ||
| func (r RowNamedValues) AsBool(fieldName string, def bool) bool { | ||
| if v, err := r.ToBool(fieldName); err == nil { | ||
| return v | ||
| } | ||
| return def | ||
| } | ||
|
|
||
| // NamedResult represents a query result with named values as opposed to ordinal values. | ||
| type NamedResult struct { | ||
| Fields []*querypb.Field `json:"fields"` | ||
| RowsAffected uint64 `json:"rows_affected"` | ||
| InsertID uint64 `json:"insert_id"` | ||
| Rows []RowNamedValues `json:"rows"` | ||
| } | ||
|
|
||
| // ToNamedResult converts a Result struct into a new NamedResult struct | ||
| func ToNamedResult(result *Result) (r *NamedResult) { | ||
| if result == nil { | ||
| return r | ||
| } | ||
| r = &NamedResult{ | ||
| Fields: result.Fields, | ||
| RowsAffected: result.RowsAffected, | ||
| InsertID: result.InsertID, | ||
| } | ||
| columnOrdinals := make(map[int]string) | ||
| for i, field := range result.Fields { | ||
| columnOrdinals[i] = field.Name | ||
| } | ||
| r.Rows = make([]RowNamedValues, len(result.Rows)) | ||
| for rowIndex, row := range result.Rows { | ||
| namedRow := make(RowNamedValues) | ||
| for i, value := range row { | ||
| namedRow[columnOrdinals[i]] = value | ||
| } | ||
| r.Rows[rowIndex] = namedRow | ||
| } | ||
| return r | ||
| } | ||
|
|
||
| // Row assumes this result has exactly one row, and returns it, or else returns nil. | ||
| // It is useful for queries like: | ||
| // - select count(*) from ... | ||
| // - select @@read_only | ||
| // - select UNIX_TIMESTAMP() from dual | ||
| func (r *NamedResult) Row() RowNamedValues { | ||
| if len(r.Rows) != 1 { | ||
| return nil | ||
| } | ||
| return r.Rows[0] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| /* | ||
| Copyright 2019 The Vitess Authors. | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| */ | ||
|
|
||
| package sqltypes | ||
|
|
||
| import ( | ||
| "reflect" | ||
| "testing" | ||
|
|
||
| querypb "vitess.io/vitess/go/vt/proto/query" | ||
| ) | ||
|
|
||
| func TestToNamedResult(t *testing.T) { | ||
| in := &Result{ | ||
| Fields: []*querypb.Field{{ | ||
| Name: "id", | ||
| Type: Int64, | ||
| }, { | ||
| Name: "status", | ||
| Type: VarChar, | ||
| }}, | ||
| InsertID: 1, | ||
| RowsAffected: 2, | ||
| Rows: [][]Value{ | ||
| {TestValue(Int64, "1"), TestValue(VarChar, "first")}, | ||
| {TestValue(Int64, "2"), TestValue(VarChar, "second")}, | ||
| {TestValue(Int64, "3"), TestValue(VarChar, "third")}, | ||
| }, | ||
| } | ||
| named := in.Named() | ||
| for i := range in.Rows { | ||
| { | ||
| want := in.Rows[i][0] | ||
| got := named.Rows[i]["id"] | ||
| if !reflect.DeepEqual(want, got) { | ||
| t.Errorf("Named:%+v\n, want:%+v\n", got, want) | ||
| } | ||
| } | ||
| { | ||
| want := in.Rows[i][1] | ||
| got := named.Rows[i]["status"] | ||
| if !reflect.DeepEqual(want, got) { | ||
| t.Errorf("Named:%+v\n, want:%+v\n", got, want) | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just out of curiosity. I can see from security perspective, installing the binary on each tablet is preferred, what are the other tradeoffs to install the binary on each tablet vs remotely on a dedicated server/pod?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right; the above is just the
localdocker setup, and so does not represent a production environment. The above is also likely temporary. At any case, an important observation is thatgh-ostreads data from MySQL and then mostly writes it back. It reads the data both by connecting into the replication stream as well as normal queries. What we've observed at GitHub is that latency between he machine wheregh-ostruns, to the MySQL servers, is important. e.g. we would only rungh-ostin same DC as affected servers. But, I think taking it to the next level and runninggh-oston the very sametablet+MySQL master servers can be beneficial.Another thing about running
gh-ostfrom dedicated servers is the amount of migrations you'd be able to run concurrently. I don't have the numbers, but I guess if you'd want to run 100 concurrent migrations (say you have 100 shards), then I suspect running 100gh-ostinstances on same dedicated server is unlikely to perform well. Actual testing needed but that's my suspicion.When you run
gh-ostright on the master server, that problem implicitly doesn't exist.