Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8c45ee1
Add CLI flags for move-tables
danieljoos May 15, 2026
1dc932b
Add switch for move-tables to main.go
danieljoos May 15, 2026
2b3fb21
First iteration of `MoveTables` migrator main function
danieljoos May 18, 2026
d8a4c2c
Add query builder for splitting up range-insert for move-tables feature
danieljoos May 15, 2026
a189729
Rename MoveTables... to MoveTable...
danieljoos May 15, 2026
5f7ff63
Add `ApplyIterationMoveTableCopyQueries` function to `Applier` to use…
danieljoos May 20, 2026
927e8cb
Add move-tables query builders to applier's prepareQueries method
danieljoos May 20, 2026
ac6f966
Call `ApplyIterationMoveTableCopyQueries` in migrator
danieljoos May 20, 2026
c151452
Adapt applier to support DML events for move tables
danieljoos May 27, 2026
d55a82f
[stash] skip ghost, changelog tables on move-tables
chriskirkland May 27, 2026
f336f8e
[WIP] flag parsing tweaks
chriskirkland May 29, 2026
bbde7b0
logging, notes debugging... halp
chriskirkland May 29, 2026
bda68c7
one more note
chriskirkland May 29, 2026
b7e87a8
seeds table in target, working up to DML events
chriskirkland May 31, 2026
bc7a24b
stash... debugging no row writes
chriskirkland Jun 1, 2026
fd68b3a
fewer errors, more debug
chriskirkland Jun 1, 2026
0508dd7
YAY
chriskirkland Jun 1, 2026
b140615
TODO
chriskirkland Jun 1, 2026
04c3ecf
[hacks] DEMO READY!
chriskirkland Jun 3, 2026
a87ab35
#8206: productionize move-tables 1.2 skip ghost/changelog/heartbeat
womoruyi Jun 5, 2026
9252fc2
#8206: productionize move-tables 1.2 skip ghost/changelog/heartbeat
womoruyi Jun 5, 2026
0dabde6
fix: address Copilot review findings on #8206 PR
womoruyi Jun 5, 2026
d249690
docs: add clarity comments to predicate-only tests per Copilot review
womoruyi Jun 5, 2026
5353a3b
fix: resolve golangci-lint errors in modified files
womoruyi Jun 5, 2026
dcecfd5
fix: last errorlint %v→%w in finalCleanup showCreateTable
womoruyi Jun 5, 2026
6ffb6ff
fix: address second Copilot review round
womoruyi Jun 5, 2026
f2a1def
Merge branch 'move-tables/applier-dml-events' into zacharysierakowski…
zacharysierakowski Jun 11, 2026
debf6af
other conflixts
zacharysierakowski Jun 11, 2026
8de52b7
couple other conflict fixes
zacharysierakowski Jun 11, 2026
caa48ed
couple other conflict fixes
zacharysierakowski Jun 11, 2026
5a799b2
couple more originalTableName
zacharysierakowski Jun 11, 2026
00aaf21
fixed GetTargetDatabaseName and called the helpers in a few other spots
zacharysierakowski Jun 11, 2026
5117dc9
got rid of TODOs
zacharysierakowski Jun 11, 2026
946a9a2
might as well toss in our test scripts for now too
zacharysierakowski Jun 11, 2026
a3550a3
dont allow CreateGhostTable in move tables mode
zacharysierakowski Jun 11, 2026
61475ff
extra cautious check on InitiateHeartbeat
zacharysierakowski Jun 11, 2026
0503bc7
removed some logs
zacharysierakowski Jun 11, 2026
3f6e53c
moar log removal
zacharysierakowski Jun 11, 2026
fcf4e61
Few more log cleanups, added TODO for final cleanup for move-tables o…
zacharysierakowski Jun 11, 2026
02d9bee
remove extra info log
zacharysierakowski Jun 11, 2026
1f1b0a4
Merge branch 'feature-move-tables' into zacharysierakowski/move-table…
zacharysierakowski Jun 11, 2026
48c94f3
fix test
zacharysierakowski Jun 11, 2026
f833b24
applier test fix
zacharysierakowski Jun 11, 2026
f813db9
check move tables mode before calling CalculateNextIterationRangeEndV…
zacharysierakowski Jun 11, 2026
25adfb5
typo in log
zacharysierakowski Jun 11, 2026
db67b29
thank you copilot
zacharysierakowski Jun 11, 2026
673d412
Potential fix for pull request finding
zacharysierakowski Jun 11, 2026
f224b44
Potential fix for pull request finding
zacharysierakowski Jun 11, 2026
1cd138e
Potential fix for pull request finding
zacharysierakowski Jun 11, 2026
cfb5d3d
copilot suggestion
zacharysierakowski Jun 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion go/base/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,24 @@ func (mctx *MigrationContext) GetGhostTableName() string {
}
}

// GetTargetTableName generates the name of the target table, based on original table name and
// the migration context (i.e. move-tables mode).
func (mctx *MigrationContext) GetTargetTableName() string {
if mctx.IsMoveTablesMode() {
return mctx.MoveTables.TableNames[0]
}
return mctx.GetGhostTableName()
}

// GetTargetDatabaseName fetches the name of the target database, which defaults to the original
// database name unless we're in move-tables mode.
func (mctx *MigrationContext) GetTargetDatabaseName() string {
if mctx.IsMoveTablesMode() {
return mctx.MoveTables.TargetDatabase
}
return mctx.DatabaseName
}

// GetOldTableName generates the name of the "old" table, into which the original table is renamed.
func (mctx *MigrationContext) GetOldTableName() string {
var tableName string
Expand Down Expand Up @@ -939,11 +957,27 @@ func (mctx *MigrationContext) ApplyCredentials() {
// Override
mctx.InspectorConnectionConfig.Password = mctx.CliPassword
}

if mctx.IsMoveTablesMode() {
// Derive the applier config from the inspector config, but point it at
// the target host and override credentials from the target CLI args.
mctx.MoveTables.ConnectionConfig = mctx.InspectorConnectionConfig.DuplicateCredentials(mysql.InstanceKey{
Hostname: mctx.MoveTables.TargetHost,
Port: mctx.MoveTables.TargetPort,
})
mctx.MoveTables.ConnectionConfig.User = mctx.MoveTables.TargetUser
mctx.MoveTables.ConnectionConfig.Password = mctx.MoveTables.TargetPass
}
}

func (mctx *MigrationContext) SetupTLS() error {
if mctx.UseTLS {
return mctx.InspectorConnectionConfig.UseTLS(mctx.TLSCACertificate, mctx.TLSCertificate, mctx.TLSKey, mctx.TLSAllowInsecure)
if err := mctx.InspectorConnectionConfig.UseTLS(mctx.TLSCACertificate, mctx.TLSCertificate, mctx.TLSKey, mctx.TLSAllowInsecure); err != nil {
return err
}
if mctx.IsMoveTablesMode() && mctx.MoveTables.ConnectionConfig != nil {
return mctx.MoveTables.ConnectionConfig.UseTLS(mctx.TLSCACertificate, mctx.TLSCertificate, mctx.TLSKey, mctx.TLSAllowInsecure)
}
}
return nil
}
Expand Down
56 changes: 56 additions & 0 deletions go/base/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,62 @@ func TestReadConfigFile(t *testing.T) {
}
}

func TestApplyCredentialsMoveTablesDerivesConnectionConfig(t *testing.T) {
ctx := NewMigrationContext()
ctx.MoveTables.TableNames = []string{"some_table"}
ctx.MoveTables.TargetHost = "target-host"
ctx.MoveTables.TargetPort = 3307
ctx.MoveTables.TargetUser = "target-user"
ctx.MoveTables.TargetPass = "target-pass"

ctx.InspectorConnectionConfig.Key.Hostname = "source-host"
ctx.InspectorConnectionConfig.Key.Port = 3306
ctx.InspectorConnectionConfig.User = "source-user"
ctx.InspectorConnectionConfig.Password = "source-pass"
ctx.InspectorConnectionConfig.Timeout = 12.5
ctx.InspectorConnectionConfig.TransactionIsolation = "REPEATABLE-READ"
ctx.InspectorConnectionConfig.Charset = "utf8mb4"

ctx.ApplyCredentials()

got := ctx.MoveTables.ConnectionConfig
require.NotNil(t, got)
require.Equal(t, "target-host", got.Key.Hostname)
require.Equal(t, 3307, got.Key.Port)
require.Equal(t, "target-user", got.User)
require.Equal(t, "target-pass", got.Password)
require.Equal(t, 12.5, got.Timeout)
require.Equal(t, "REPEATABLE-READ", got.TransactionIsolation)
require.Equal(t, "utf8mb4", got.Charset)
require.NotNil(t, got.ImpliedKey)
require.Equal(t, "target-host", got.ImpliedKey.Hostname)
require.Equal(t, 3307, got.ImpliedKey.Port)
}

func TestSetupTLSAppliesToMoveTablesConfig(t *testing.T) {
ctx := NewMigrationContext()
ctx.UseTLS = true
ctx.TLSAllowInsecure = true
ctx.MoveTables.TableNames = []string{"some_table"}
ctx.MoveTables.TargetHost = "target-host"
ctx.MoveTables.TargetPort = 3307
ctx.MoveTables.TargetUser = "target-user"
ctx.MoveTables.TargetPass = "target-pass"

ctx.InspectorConnectionConfig.Key.Hostname = "source-host"
ctx.InspectorConnectionConfig.Key.Port = 3306
ctx.InspectorConnectionConfig.User = "source-user"
ctx.InspectorConnectionConfig.Password = "source-pass"

ctx.ApplyCredentials()
require.NoError(t, ctx.SetupTLS())

require.NotNil(t, ctx.InspectorConnectionConfig.TLSConfig())
require.NotNil(t, ctx.MoveTables.ConnectionConfig.TLSConfig())
require.Equal(t, "source-host", ctx.InspectorConnectionConfig.TLSConfig().ServerName)
require.Equal(t, "target-host", ctx.MoveTables.ConnectionConfig.TLSConfig().ServerName)
}

func TestSetAbortError_StoresFirstError(t *testing.T) {
ctx := NewMigrationContext()

Expand Down
15 changes: 9 additions & 6 deletions go/cmd/gh-ost/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/github/gh-ost/go/base"
"github.com/github/gh-ost/go/logic"
"github.com/github/gh-ost/go/metrics"
"github.com/github/gh-ost/go/mysql"
"github.com/github/gh-ost/go/sql"
_ "github.com/go-sql-driver/mysql"
"github.com/openark/golib/log"
Expand Down Expand Up @@ -233,12 +234,6 @@ func main() {
migrationContext.Log.SetLevel(log.ERROR)
}

if err := migrationContext.SetConnectionConfig(*storageEngine); err != nil {
migrationContext.Log.Fatale(err)
}

migrationContext.SetConnectionCharset(*charset)

if migrationContext.AlterStatement == "" && !migrationContext.Revert && *moveTables == "" {
log.Fatal("--alter must be provided and statement must not be empty, or --revert must be used, or --move-tables must be used")
}
Expand Down Expand Up @@ -379,6 +374,7 @@ func main() {
// For now, we only support moving a single table at a time.
log.Fatal("--move-tables currently supports only a single table")
}

if migrationContext.MoveTables.TargetUser == "" {
migrationContext.MoveTables.TargetUser = migrationContext.CliUser
}
Expand All @@ -388,8 +384,15 @@ func main() {
if migrationContext.MoveTables.TargetDatabase == "" {
migrationContext.MoveTables.TargetDatabase = migrationContext.DatabaseName
}
migrationContext.MoveTables.ConnectionConfig = mysql.NewConnectionConfig()
}

if err := migrationContext.SetConnectionConfig(*storageEngine); err != nil {
migrationContext.Log.Fatale(err)
}

migrationContext.SetConnectionCharset(*charset)

switch *cutOver {
case "atomic", "default", "":
migrationContext.CutOverType = base.CutOverAtomic
Expand Down
Loading
Loading