9
9
gosql "database/sql"
10
10
"fmt"
11
11
"strings"
12
- "sync"
13
12
"sync/atomic"
14
13
"time"
15
14
@@ -904,7 +903,7 @@ func (this *Applier) CreateAtomicCutOverSentryTable() error {
904
903
}
905
904
906
905
// AtomicCutOverMagicLock
907
- func (this * Applier ) AtomicCutOverMagicLock (sessionIdChan chan int64 , tableLocked chan <- error , okToUnlockTable <- chan bool , tableUnlocked chan <- error , dropCutOverSentryTableOnce * sync. Once ) error {
906
+ func (this * Applier ) AtomicCutOverMagicLock (sessionIdChan chan int64 , tableLocked chan <- error , okToUnlockTable <- chan bool , tableUnlocked chan <- error ) error {
908
907
tx , err := this .db .Begin ()
909
908
if err != nil {
910
909
tableLocked <- err
@@ -915,6 +914,7 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
915
914
tableLocked <- fmt .Errorf ("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads" )
916
915
tableUnlocked <- fmt .Errorf ("Unexpected error in AtomicCutOverMagicLock(), injected to release blocking channel reads" )
917
916
tx .Rollback ()
917
+ this .DropAtomicCutOverSentryTableIfExists ()
918
918
}()
919
919
920
920
var sessionId int64
@@ -983,12 +983,10 @@ func (this *Applier) AtomicCutOverMagicLock(sessionIdChan chan int64, tableLocke
983
983
sql .EscapeName (this .migrationContext .GetOldTableName ()),
984
984
)
985
985
986
- dropCutOverSentryTableOnce .Do (func () {
987
- if _ , err := tx .Exec (query ); err != nil {
988
- this .migrationContext .Log .Errore (err )
989
- // We DO NOT return here because we must `UNLOCK TABLES`!
990
- }
991
- })
986
+ if _ , err := tx .Exec (query ); err != nil {
987
+ this .migrationContext .Log .Errore (err )
988
+ // We DO NOT return here because we must `UNLOCK TABLES`!
989
+ }
992
990
993
991
// Tables still locked
994
992
this .migrationContext .Log .Infof ("Releasing lock from %s.%s, %s.%s" ,
0 commit comments