@@ -17,6 +17,7 @@ import (
17
17
"github.com/github/gh-ost/go/sql"
18
18
19
19
"github.com/outbrain/golib/sqlutils"
20
+ "sync"
20
21
)
21
22
22
23
const (
@@ -787,7 +788,7 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
787
788
}
788
789
789
790
// 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 {
791
792
tx , err := this .db .Begin ()
792
793
if err != nil {
793
794
tableLocked <- err
@@ -865,10 +866,13 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
865
866
sql .EscapeName (this .migrationContext .DatabaseName ),
866
867
sql .EscapeName (this .migrationContext .GetOldTableName ()),
867
868
)
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
+ })
872
876
873
877
// Tables still locked
874
878
this .migrationContext .Log .Infof ("Releasing lock from %s.%s, %s.%s" ,
0 commit comments