Skip to content

Commit 8a4efcd

Browse files
committed
Added logic to remove the triggers in case of error and created channel
1 parent 4f501fe commit 8a4efcd

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

go/logic/applier.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,17 +649,17 @@ func (this *Applier) DropTriggersOldTable() error {
649649
prefix := this.makeTriggerPrefix()
650650

651651
dropDeleteTrigger := fmt.Sprintf(
652-
"DROP /* gh-ost */ TRIGGER %s.`%s_del`",
652+
"DROP /* gh-ost */ TRIGGER IF EXISTS %s.`%s_del`",
653653
sql.EscapeName(this.migrationContext.DatabaseName),
654654
prefix)
655655

656656
dropInsertTrigger := fmt.Sprintf(
657-
"DROP /* gh-ost */ TRIGGER %s.`%s_ins`",
657+
"DROP /* gh-ost */ TRIGGER IF EXISTS %s.`%s_ins`",
658658
sql.EscapeName(this.migrationContext.DatabaseName),
659659
prefix)
660660

661661
dropUpdateTrigger := fmt.Sprintf(
662-
"DROP /* gh-ost */ TRIGGER %s.`%s_upd`",
662+
"DROP /* gh-ost */ TRIGGER IF EXISTS %s.`%s_upd`",
663663
sql.EscapeName(this.migrationContext.DatabaseName),
664664
prefix)
665665

go/logic/migrator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func NewMigrator(context *base.MigrationContext) *Migrator {
100100
firstThrottlingCollected: make(chan bool, 3),
101101
rowCopyComplete: make(chan error),
102102
allEventsUpToLockProcessed: make(chan string),
103+
stoppedBinlogWrites: make(chan bool),
103104
allEventsUpToTriggersProcessed: make(chan string),
104105

105106
copyRowsQueue: make(chan tableWriteFunc),
@@ -692,6 +693,8 @@ func (this *Migrator) cutOverTrigger() (err error) {
692693

693694
this.waitForStopWrites()
694695

696+
defer this.applier.DropTriggersOldTable()
697+
695698
log.Infof(
696699
"Creating triggers for %s.%s",
697700
this.migrationContext.DatabaseName,

0 commit comments

Comments
 (0)