@@ -17,6 +17,7 @@ import (
1717 "github.com/github/gh-ost/go/sql"
1818
1919 "github.com/outbrain/golib/sqlutils"
20+ "sync"
2021)
2122
2223const (
@@ -787,7 +788,7 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
787788}
788789
789790// AtomicCutOverMagicLock
790- func (this * Applier ) AtomicCutOverMagicLock (sessionIdChan chan int64 , tableLocked chan <- error , okToUnlockTable <- chan bool , tableUnlocked chan <- error ) error {
791+ func (this * Applier ) AtomicCutOverMagicLock (sessionIdChan chan int64 , tableLocked chan <- error , okToUnlockTable <- chan bool , tableUnlocked chan <- error , dropCutOverSentryTableOnce * sync. Once ) error {
791792 tx , err := this .db .Begin ()
792793 if err != nil {
793794 tableLocked <- err
@@ -865,10 +866,13 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
865866 sql .EscapeName (this .migrationContext .DatabaseName ),
866867 sql .EscapeName (this .migrationContext .GetOldTableName ()),
867868 )
868- if _ , err := tx .Exec (query ); err != nil {
869- this .migrationContext .Log .Errore (err )
870- // We DO NOT return here because we must `UNLOCK TABLES`!
871- }
869+
870+ dropCutOverSentryTableOnce .Do (func () {
871+ if _ , err := tx .Exec (query ); err != nil {
872+ this .migrationContext .Log .Errore (err )
873+ // We DO NOT return here because we must `UNLOCK TABLES`!
874+ }
875+ })
872876
873877 // Tables still locked
874878 this .migrationContext .Log .Infof ("Releasing lock from %s.%s, %s.%s" ,
0 commit comments