Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions doc/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ The following variables are available on all hooks:

The following variable are available on particular hooks:

- `GH_OST_INSTANT_DDL` is only available in `gh-ost-on-success`. The value is true if instant DDL was successful.
- `GH_OST_COMMAND` is only available in `gh-ost-on-interactive-command`
- `GH_OST_STATUS` is only available in `gh-ost-on-status`
- `GH_OST_LAST_BATCH_COPY_ERROR` is only available in `gh-ost-on-batch-copy-retry`
Expand Down
5 changes: 3 additions & 2 deletions go/logic/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ func (this *HooksExecutor) onInteractiveCommand(command string) error {
return this.executeHooks(onInteractiveCommand, v)
}

func (this *HooksExecutor) onSuccess() error {
return this.executeHooks(onSuccess)
func (this *HooksExecutor) onSuccess(instantDDL bool) error {
v := fmt.Sprintf("GH_OST_INSTANT_DDL=%t", instantDDL)
return this.executeHooks(onSuccess, v)
}

func (this *HooksExecutor) onFailure() error {
Expand Down
7 changes: 4 additions & 3 deletions go/logic/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,14 @@ func (this *Migrator) Migrate() (err error) {
if this.migrationContext.AttemptInstantDDL {
if this.migrationContext.Noop {
this.migrationContext.Log.Debugf("Noop operation; not really attempting instant DDL")
return this.hooksExecutor.onSuccess(true)
} else {
this.migrationContext.Log.Infof("Attempting to execute alter with ALGORITHM=INSTANT")
if err := this.applier.AttemptInstantDDL(); err == nil {
if err := this.finalCleanup(); err != nil {
return nil
}
if err := this.hooksExecutor.onSuccess(); err != nil {
if err := this.hooksExecutor.onSuccess(true); err != nil {
return err
}
this.migrationContext.Log.Infof("Success! table %s.%s migrated instantly", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
Expand Down Expand Up @@ -620,7 +621,7 @@ func (this *Migrator) Migrate() (err error) {
if err := this.finalCleanup(); err != nil {
return nil
}
if err := this.hooksExecutor.onSuccess(); err != nil {
if err := this.hooksExecutor.onSuccess(false); err != nil {
return err
}
this.migrationContext.Log.Infof("Done migrating %s.%s", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
Expand Down Expand Up @@ -734,7 +735,7 @@ func (this *Migrator) Revert() error {
if err := this.finalCleanup(); err != nil {
return nil
}
if err := this.hooksExecutor.onSuccess(); err != nil {
if err := this.hooksExecutor.onSuccess(false); err != nil {
return err
}
this.migrationContext.Log.Infof("Done reverting %s.%s", sql.EscapeName(this.migrationContext.DatabaseName), sql.EscapeName(this.migrationContext.OriginalTableName))
Expand Down
Loading