Skip to content

Commit 298d0ee

Browse files
authored
Merge branch 'master' into varun/fix-alleventsuptolockprocessed-deadlock
2 parents 9bf9d5e + 0270a28 commit 298d0ee

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

doc/hooks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ The following variables are available on all hooks:
8181

8282
The following variable are available on particular hooks:
8383

84+
- `GH_OST_INSTANT_DDL` is only available in `gh-ost-on-success`. The value is `true` if instant DDL was successful, and `false` if it was not.
8485
- `GH_OST_COMMAND` is only available in `gh-ost-on-interactive-command`
8586
- `GH_OST_STATUS` is only available in `gh-ost-on-status`
8687
- `GH_OST_LAST_BATCH_COPY_ERROR` is only available in `gh-ost-on-batch-copy-retry`

go/logic/hooks.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ func (this *HooksExecutor) onInteractiveCommand(command string) error {
148148
return this.executeHooks(onInteractiveCommand, v)
149149
}
150150

151-
func (this *HooksExecutor) onSuccess() error {
152-
return this.executeHooks(onSuccess)
151+
func (this *HooksExecutor) onSuccess(instantDDL bool) error {
152+
v := fmt.Sprintf("GH_OST_INSTANT_DDL=%t", instantDDL)
153+
return this.executeHooks(onSuccess, v)
153154
}
154155

155156
func (this *HooksExecutor) onFailure() error {

go/logic/hooks_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ func TestHooksExecutorExecuteHooks(t *testing.T) {
105105
require.Equal(t, 50.0, progress)
106106
case "GH_OST_TABLE_NAME":
107107
require.Equal(t, migrationContext.OriginalTableName, split[1])
108+
case "GH_OST_INSTANT_DDL":
109+
require.Equal(t, "false", split[1])
108110
case "TEST":
109111
require.Equal(t, t.Name(), split[1])
110112
}

go/logic/migrator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ func (this *Migrator) Migrate() (err error) {
492492
if err := this.finalCleanup(); err != nil {
493493
return nil
494494
}
495-
if err := this.hooksExecutor.onSuccess(); err != nil {
495+
if err := this.hooksExecutor.onSuccess(true); err != nil {
496496
return err
497497
}
498498
this.migrationContext.Log.Infof("Success! table %s.%s migrated instantly", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
@@ -628,7 +628,7 @@ func (this *Migrator) Migrate() (err error) {
628628
if err := this.finalCleanup(); err != nil {
629629
return nil
630630
}
631-
if err := this.hooksExecutor.onSuccess(); err != nil {
631+
if err := this.hooksExecutor.onSuccess(false); err != nil {
632632
return err
633633
}
634634
this.migrationContext.Log.Infof("Done migrating %s.%s", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
@@ -742,7 +742,7 @@ func (this *Migrator) Revert() error {
742742
if err := this.finalCleanup(); err != nil {
743743
return nil
744744
}
745-
if err := this.hooksExecutor.onSuccess(); err != nil {
745+
if err := this.hooksExecutor.onSuccess(false); err != nil {
746746
return err
747747
}
748748
this.migrationContext.Log.Infof("Done reverting %s.%s", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))

0 commit comments

Comments
 (0)